Skip to content

Commit 44b12c1

Browse files
refacktargos
authored andcommitted
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. Backport-PR-URL: #19579 PR-URL: #13686 Fixes: #13682 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michaël Zasso <[email protected]>
1 parent cc68bc2 commit 44b12c1

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
@@ -689,6 +689,11 @@ exports.expectsError = function expectsError(fn, settings, exact) {
689689
}
690690
assert(error instanceof type,
691691
`${error.name} is not instance of ${type.name}`);
692+
let typeName = error.constructor.name;
693+
if (typeName === 'NodeError' && type.name !== 'NodeError') {
694+
typeName = Object.getPrototypeOf(error.constructor).name;
695+
}
696+
assert.strictEqual(typeName, type.name);
692697
}
693698
if ('message' in settings) {
694699
const message = settings.message;

0 commit comments

Comments
 (0)