Skip to content

Commit

Permalink
test: fix common.expectsError
Browse files Browse the repository at this point in the history
The function should strictly test for the error class and only accept
the correct one. Any other error class should fail.

Backport-PR-URL: #19579
PR-URL: #13686
Fixes: #13682
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
  • Loading branch information
refack authored and targos committed Mar 30, 2018
1 parent cc68bc2 commit 44b12c1
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,11 @@ exports.expectsError = function expectsError(fn, settings, exact) {
}
assert(error instanceof type,
`${error.name} is not instance of ${type.name}`);
let typeName = error.constructor.name;
if (typeName === 'NodeError' && type.name !== 'NodeError') {
typeName = Object.getPrototypeOf(error.constructor).name;
}
assert.strictEqual(typeName, type.name);
}
if ('message' in settings) {
const message = settings.message;
Expand Down

0 comments on commit 44b12c1

Please sign in to comment.