Skip to content

Commit

Permalink
test: replace assert.throws with common.expectsError
Browse files Browse the repository at this point in the history
PR-URL: #17445
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
Leko authored and maclover7 committed Dec 6, 2017
1 parent b73e66e commit 50afd90
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions test/addons-napi/test_error/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,29 +60,26 @@ assert.throws(() => {
test_error.throwTypeError();
}, /^TypeError: type error$/);

assert.throws(
common.expectsError(
() => test_error.throwErrorCode(),
common.expectsError({
{
code: 'ERR_TEST_CODE',
message: 'Error [error]'
})
);
});

assert.throws(
common.expectsError(
() => test_error.throwRangeErrorCode(),
common.expectsError({
{
code: 'ERR_TEST_CODE',
message: 'RangeError [range error]'
})
);
});

assert.throws(
common.expectsError(
() => test_error.throwTypeErrorCode(),
common.expectsError({
{
code: 'ERR_TEST_CODE',
message: 'TypeError [type error]'
})
);
});

let error = test_error.createError();
assert.ok(error instanceof Error, 'expected error to be an instance of Error');
Expand Down

0 comments on commit 50afd90

Please sign in to comment.