Skip to content

Commit 95ff8f0

Browse files
refackMylesBorins
authored andcommittedJan 9, 2018
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 <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent 103bfa1 commit 95ff8f0

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed
 

‎test/common/index.js

+5
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,11 @@ exports.expectsError = function expectsError(fn, settings, exact) {
744744
}
745745
assert(error instanceof type,
746746
`${error.name} is not instance of ${type.name}`);
747+
let typeName = error.constructor.name;
748+
if (typeName === 'NodeError' && type.name !== 'NodeError') {
749+
typeName = Object.getPrototypeOf(error.constructor).name;
750+
}
751+
assert.strictEqual(typeName, type.name);
747752
}
748753
if ('message' in settings) {
749754
const message = settings.message;

0 commit comments

Comments
 (0)
Please sign in to comment.