Skip to content

Commit

Permalink
test: replace assert.throws with common.expectsError
Browse files Browse the repository at this point in the history
Backport-PR-URL: #19447
PR-URL: #17445
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Jon Moss <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
Leko authored and MylesBorins committed Apr 16, 2018
1 parent 173f297 commit e54b58c
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 e54b58c

Please sign in to comment.