Permalink
Browse files

test: remove ambiguous error messages from test_error

assert.strictEqual accepts 3 arguments, the last of which allows for
user-specified error message to be thrown when the assertion fails.
Unfortunately, this error message is less helpful than the default when
it is vague. This commit removes vague, user-specified error messages,
instead relying on clearer, default error messages.

PR-URL: #17812
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
  • Loading branch information...
nadrane authored and Trott committed Dec 21, 2017
1 parent 457ceeb commit 094d92bb57207fbc184bf15ef83591416333f1cf
Showing with 12 additions and 34 deletions.
  1. +12 −34 test/addons-napi/test_error/test.js
@@ -83,56 +83,34 @@ common.expectsError(
let error = test_error.createError();
assert.ok(error instanceof Error, 'expected error to be an instance of Error');
assert.strictEqual(error.message, 'error', 'expected message to be "error"');
assert.strictEqual(error.message, 'error');
error = test_error.createRangeError();
assert.ok(error instanceof RangeError,
'expected error to be an instance of RangeError');
assert.strictEqual(error.message,
'range error',
'expected message to be "range error"');
assert.strictEqual(error.message, 'range error');
error = test_error.createTypeError();
assert.ok(error instanceof TypeError,
'expected error to be an instance of TypeError');
assert.strictEqual(error.message,
'type error',
'expected message to be "type error"');
assert.strictEqual(error.message, 'type error');
error = test_error.createErrorCode();
assert.ok(error instanceof Error, 'expected error to be an instance of Error');
assert.strictEqual(error.code,
'ERR_TEST_CODE',
'expected code to be "ERR_TEST_CODE"');
assert.strictEqual(error.message,
'Error [error]',
'expected message to be "Error [error]"');
assert.strictEqual(error.name,
'Error [ERR_TEST_CODE]',
'expected name to be "Error [ERR_TEST_CODE]"');
assert.strictEqual(error.code, 'ERR_TEST_CODE');
assert.strictEqual(error.message, 'Error [error]');
assert.strictEqual(error.name, 'Error [ERR_TEST_CODE]');
error = test_error.createRangeErrorCode();
assert.ok(error instanceof RangeError,
'expected error to be an instance of RangeError');
assert.strictEqual(error.message,
'RangeError [range error]',
'expected message to be "RangeError [range error]"');
assert.strictEqual(error.code,
'ERR_TEST_CODE',
'expected code to be "ERR_TEST_CODE"');
assert.strictEqual(error.name,
'RangeError [ERR_TEST_CODE]',
'expected name to be "RangeError[ERR_TEST_CODE]"');
assert.strictEqual(error.message, 'RangeError [range error]');
assert.strictEqual(error.code, 'ERR_TEST_CODE');
assert.strictEqual(error.name, 'RangeError [ERR_TEST_CODE]');
error = test_error.createTypeErrorCode();
assert.ok(error instanceof TypeError,
'expected error to be an instance of TypeError');
assert.strictEqual(error.message,
'TypeError [type error]',
'expected message to be "TypeError [type error]"');
assert.strictEqual(error.code,
'ERR_TEST_CODE',
'expected code to be "ERR_TEST_CODE"');
assert.strictEqual(error.name,
'TypeError [ERR_TEST_CODE]',
'expected name to be "TypeError[ERR_TEST_CODE]"');
assert.strictEqual(error.message, 'TypeError [type error]');
assert.strictEqual(error.code, 'ERR_TEST_CODE');
assert.strictEqual(error.name, 'TypeError [ERR_TEST_CODE]');

0 comments on commit 094d92b

Please sign in to comment.