Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
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).
  • Loading branch information
BridgeAR committed Apr 26, 2018
commit 6202d98657f119cf1c8c1947786c11154ad04b70
5 changes: 5 additions & 0 deletions test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down