Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: remove ambiguous error messages from test_error #17812

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 12 additions & 23 deletions test/addons-napi/test_error/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,56 +83,45 @@ 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"');
'range error');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: can you please put this (and the others) on the same line now that it doesn't exceed 80 chars?


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"');
'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"');
'ERR_TEST_CODE');
assert.strictEqual(error.message,
'Error [error]',
'expected message to be "Error [error]"');
'Error [error]');
assert.strictEqual(error.name,
'Error [ERR_TEST_CODE]',
'expected name to be "Error [ERR_TEST_CODE]"');
'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]"');
'RangeError [range error]');
assert.strictEqual(error.code,
'ERR_TEST_CODE',
'expected code to be "ERR_TEST_CODE"');
'ERR_TEST_CODE');
assert.strictEqual(error.name,
'RangeError [ERR_TEST_CODE]',
'expected name to be "RangeError[ERR_TEST_CODE]"');
'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]"');
'TypeError [type error]');
assert.strictEqual(error.code,
'ERR_TEST_CODE',
'expected code to be "ERR_TEST_CODE"');
'ERR_TEST_CODE');
assert.strictEqual(error.name,
'TypeError [ERR_TEST_CODE]',
'expected name to be "TypeError[ERR_TEST_CODE]"');
'TypeError [ERR_TEST_CODE]');