summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2017-12-09 21:47:49 -0200
committerRuben Bridgewater <ruben@bridgewater.de>2017-12-19 13:43:11 -0300
commitda5c7d68cdceaa70411ffab6bee16e200a703aa9 (patch)
treef0b9658290f2ea05c5bb777748bf35af5f79367d /test
parentdc2e266647cec8ba3e6f61d6da90001fa8c5649f (diff)
downloadnode-new-da5c7d68cdceaa70411ffab6bee16e200a703aa9.tar.gz
assert: improve assert.throws
Throw a TypeError in case a error message is provided in the second argument and a third argument is present as well. This is clearly a mistake and should not be done. PR-URL: https://github.com/nodejs/node/pull/17585 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Evan Lucas <evanlucas@me.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-assert.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js
index 3078d1ce51..27714e22fc 100644
--- a/test/parallel/test-assert.js
+++ b/test/parallel/test-assert.js
@@ -773,3 +773,14 @@ common.expectsError(
message: 'null == true'
}
);
+
+common.expectsError(
+ // eslint-disable-next-line no-restricted-syntax
+ () => assert.throws(() => {}, 'Error message', 'message'),
+ {
+ code: 'ERR_INVALID_ARG_TYPE',
+ type: TypeError,
+ message: 'The "error" argument must be one of type Function or RegExp. ' +
+ 'Received type string'
+ }
+);