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 aa341d1

Browse filesBrowse files
BridgeARBethGriggs
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). Backport-PR-URL: #22850 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 28a6e59 commit aa341d1
Copy full SHA for aa341d1

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
@@ -691,6 +691,11 @@ exports.expectsError = function expectsError(fn, settings, exact) {
691691
fn = undefined;
692692
}
693693
function innerFn(error) {
694+
if (arguments.length !== 1) {
695+
// Do not use `assert.strictEqual()` to prevent `util.inspect` from
696+
// always being called.
697+
assert.fail(`Expected one argument, got ${util.inspect(arguments)}`);
698+
}
694699
assert.strictEqual(error.code, settings.code);
695700
const descriptor = Object.getOwnPropertyDescriptor(error, 'message');
696701
assert.strictEqual(descriptor.enumerable,

0 commit comments

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