Skip to content

Commit

Permalink
test: increase error information in test-cli-syntax-*
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-By: Anto Aravinth <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Shelley Vohr <[email protected]>
Reviewed-By: Daijiro Wachi <[email protected]>
  • Loading branch information
Trott authored and BethGriggs committed Apr 8, 2019
1 parent 92792f0 commit 7cceecf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion test/sequential/test-cli-syntax-bad.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ const syntaxErrorRE = /^SyntaxError: \b/m;
const cmd = [node, ..._args].join(' ');
exec(cmd, common.mustCall((err, stdout, stderr) => {
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
assert.strictEqual(stdout, '');
Expand Down
3 changes: 2 additions & 1 deletion test/sequential/test-cli-syntax-file-not-found.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ const notFoundRE = /^Error: Cannot find module/m;
// stderr should have a module not found error message
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}`);
}));
});
});
3 changes: 2 additions & 1 deletion test/sequential/test-cli-syntax-require.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ const syntaxErrorRE = /^SyntaxError: \b/m;
const cmd = [node, ...args].join(' ');
exec(cmd, common.mustCall((err, stdout, stderr) => {
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
assert.strictEqual(stdout, '');
Expand Down

0 comments on commit 7cceecf

Please sign in to comment.