Skip to content
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
Prev Previous commit
Next Next commit
test: fix common.expectsError
The function should strictly test for the error class and only accept
the correct one. Any other error class should fail.

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 24, 2018
commit fd9467196f4be75a35fd278e9810fb0fe89db97f
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