Skip to content

Commit 29d99c1

Browse files
refackBridgeAR
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. PR-URL: nodejs#13686 Fixes: nodejs#13682 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
1 parent f26cabb commit 29d99c1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

test/common/index.js

Lines changed: 5 additions & 0 deletions
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)