From 914c49497cd92a9266cf5aaed1f425358d1023cc Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 13 Dec 2018 09:17:35 -0800 Subject: 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 Reviewed-By: Anto Aravinth Reviewed-By: Colin Ihrig Reviewed-By: Shelley Vohr Reviewed-By: Daijiro Wachi --- test/sequential/test-cli-syntax-bad.js | 3 ++- test/sequential/test-cli-syntax-file-not-found.js | 3 ++- test/sequential/test-cli-syntax-require.js | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/test/sequential/test-cli-syntax-bad.js b/test/sequential/test-cli-syntax-bad.js index e1c7f3bec5..7c4c9c70d9 100644 --- a/test/sequential/test-cli-syntax-bad.js +++ b/test/sequential/test-cli-syntax-bad.js @@ -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, ''); diff --git a/test/sequential/test-cli-syntax-file-not-found.js b/test/sequential/test-cli-syntax-file-not-found.js index 848e2fe231..b90033a396 100644 --- a/test/sequential/test-cli-syntax-file-not-found.js +++ b/test/sequential/test-cli-syntax-file-not-found.js @@ -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}`); })); }); }); diff --git a/test/sequential/test-cli-syntax-require.js b/test/sequential/test-cli-syntax-require.js index ed13805eb9..d99dc2ff71 100644 --- a/test/sequential/test-cli-syntax-require.js +++ b/test/sequential/test-cli-syntax-require.js @@ -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, ''); -- cgit v1.2.3