diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2018-04-26 02:14:25 +0200 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2018-04-29 17:13:37 +0200 |
commit | 29cddb40b238daf1dfad0cc42e0d3bd5068dff03 (patch) | |
tree | 6cfcbb123d7cefff28555b23f363898cf929d1f4 /test/common/index.js | |
parent | bb546ac001356da4dffd762c3f847660210f3064 (diff) | |
download | android-node-v8-29cddb40b238daf1dfad0cc42e0d3bd5068dff03.tar.gz android-node-v8-29cddb40b238daf1dfad0cc42e0d3bd5068dff03.tar.bz2 android-node-v8-29cddb40b238daf1dfad0cc42e0d3bd5068dff03.zip |
test: verify arguments length in common.expectsError
If `common.expectsError` is used as a callback, it will now also
verify that there is only one argument (the expected error).
PR-URL: https://github.com/nodejs/node/pull/20311
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Diffstat (limited to 'test/common/index.js')
-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 95bb8dd804..bbd2b62d7d 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -708,6 +708,11 @@ exports.expectsError = function expectsError(fn, settings, exact) { } function innerFn(error) { + if (arguments.length !== 1) { + // Do not use `assert.strictEqual()` to prevent `util.inspect` from + // always being called. + assert.fail(`Expected one argument, got ${util.inspect(arguments)}`); + } const descriptor = Object.getOwnPropertyDescriptor(error, 'message'); assert.strictEqual(descriptor.enumerable, false, 'The error message should be non-enumerable'); |