Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 645a97a

Browse filesBrowse files
BridgeARMylesBorins
authored andcommitted
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: #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>
1 parent 7d9f1f3 commit 645a97a
Copy full SHA for 645a97a

File tree

Expand file treeCollapse file tree

1 file changed

+5
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+5
-0
lines changed
Open diff view settings
Collapse file

‎test/common/index.js‎

Copy file name to clipboardExpand all lines: test/common/index.js
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,11 @@ exports.expectsError = function expectsError(fn, settings, exact) {
708708
}
709709

710710
function innerFn(error) {
711+
if (arguments.length !== 1) {
712+
// Do not use `assert.strictEqual()` to prevent `util.inspect` from
713+
// always being called.
714+
assert.fail(`Expected one argument, got ${util.inspect(arguments)}`);
715+
}
711716
const descriptor = Object.getOwnPropertyDescriptor(error, 'message');
712717
assert.strictEqual(descriptor.enumerable,
713718
false, 'The error message should be non-enumerable');

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.