diff options
author | Refael Ackermann <refack@gmail.com> | 2017-06-14 15:47:19 -0400 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2018-01-06 04:04:29 +0100 |
commit | 29d99c1885cc99c955543df33b9f43d48158fc0d (patch) | |
tree | 5747074e38854b81e18e39bcb299804c3c9375ac /test | |
parent | f26cabbe249ae6e095736ef65bd925fb82c4908c (diff) | |
download | android-node-v8-29d99c1885cc99c955543df33b9f43d48158fc0d.tar.gz android-node-v8-29d99c1885cc99c955543df33b9f43d48158fc0d.tar.bz2 android-node-v8-29d99c1885cc99c955543df33b9f43d48158fc0d.zip |
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: https://github.com/nodejs/node/pull/13686
Fixes: https://github.com/nodejs/node/issues/13682
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/common/index.js | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/test/common/index.js b/test/common/index.js index 7a2cebac5f..e6236b1be6 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -744,6 +744,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; |