test: increase error information in test-cli-syntax-*
If there is an error, but not the error code the test expects, display more information about the error. PR-URL: https://github.com/nodejs/node/pull/25021 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Shelley Vohr <codebytere@gmail.com> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
This commit is contained in:
parent
80ab537ee6
commit
914c49497c
@ -32,7 +32,8 @@ const syntaxErrorRE = /^SyntaxError: \b/m;
|
|||||||
const cmd = [node, ..._args].join(' ');
|
const cmd = [node, ..._args].join(' ');
|
||||||
exec(cmd, common.mustCall((err, stdout, stderr) => {
|
exec(cmd, common.mustCall((err, stdout, stderr) => {
|
||||||
assert.strictEqual(err instanceof Error, true);
|
assert.strictEqual(err instanceof Error, true);
|
||||||
assert.strictEqual(err.code, 1);
|
assert.strictEqual(err.code, 1,
|
||||||
|
`code ${err.code} !== 1 for error:\n\n${err}`);
|
||||||
|
|
||||||
// no stdout should be produced
|
// no stdout should be produced
|
||||||
assert.strictEqual(stdout, '');
|
assert.strictEqual(stdout, '');
|
||||||
|
@ -33,7 +33,8 @@ const notFoundRE = /^Error: Cannot find module/m;
|
|||||||
// stderr should have a module not found error message
|
// stderr should have a module not found error message
|
||||||
assert(notFoundRE.test(stderr), `${notFoundRE} === ${stderr}`);
|
assert(notFoundRE.test(stderr), `${notFoundRE} === ${stderr}`);
|
||||||
|
|
||||||
assert.strictEqual(err.code, 1);
|
assert.strictEqual(err.code, 1,
|
||||||
|
`code ${err.code} !== 1 for error:\n\n${err}`);
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -20,7 +20,8 @@ const syntaxErrorRE = /^SyntaxError: \b/m;
|
|||||||
const cmd = [node, ...args].join(' ');
|
const cmd = [node, ...args].join(' ');
|
||||||
exec(cmd, common.mustCall((err, stdout, stderr) => {
|
exec(cmd, common.mustCall((err, stdout, stderr) => {
|
||||||
assert.strictEqual(err instanceof Error, true);
|
assert.strictEqual(err instanceof Error, true);
|
||||||
assert.strictEqual(err.code, 1);
|
assert.strictEqual(err.code, 1,
|
||||||
|
`code ${err.code} !== 1 for error:\n\n${err}`);
|
||||||
|
|
||||||
// no stdout should be produced
|
// no stdout should be produced
|
||||||
assert.strictEqual(stdout, '');
|
assert.strictEqual(stdout, '');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user