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:
parent
bb546ac001
commit
29cddb40b2
@ -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');
|
||||
|
Loading…
x
Reference in New Issue
Block a user