mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
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>
This commit is contained in:
1 file changed
+5
@@ -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');
|
||||
|
||||
Reference in new issue
Block a user