Skip to content

Commit 900a412

Browse files
TrottBethGriggs
authored andcommitted
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: #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>
1 parent f43f45a commit 900a412

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

test/sequential/test-cli-syntax-bad.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ const syntaxErrorRE = /^SyntaxError: \b/m;
3232
const cmd = [node, ..._args].join(' ');
3333
exec(cmd, common.mustCall((err, stdout, stderr) => {
3434
assert.strictEqual(err instanceof Error, true);
35-
assert.strictEqual(err.code, 1);
35+
assert.strictEqual(err.code, 1,
36+
`code ${err.code} !== 1 for error:\n\n${err}`);
3637

3738
// no stdout should be produced
3839
assert.strictEqual(stdout, '');

test/sequential/test-cli-syntax-file-not-found.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ const notFoundRE = /^Error: Cannot find module/m;
3333
// stderr should have a module not found error message
3434
assert(notFoundRE.test(stderr), `${notFoundRE} === ${stderr}`);
3535

36-
assert.strictEqual(err.code, 1);
36+
assert.strictEqual(err.code, 1,
37+
`code ${err.code} !== 1 for error:\n\n${err}`);
3738
}));
3839
});
3940
});

test/sequential/test-cli-syntax-require.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ const syntaxErrorRE = /^SyntaxError: \b/m;
2020
const cmd = [node, ...args].join(' ');
2121
exec(cmd, common.mustCall((err, stdout, stderr) => {
2222
assert.strictEqual(err instanceof Error, true);
23-
assert.strictEqual(err.code, 1);
23+
assert.strictEqual(err.code, 1,
24+
`code ${err.code} !== 1 for error:\n\n${err}`);
2425

2526
// no stdout should be produced
2627
assert.strictEqual(stdout, '');

0 commit comments

Comments
 (0)