Skip to content

Commit 3e0d40d

Browse files
committed
test: add info option to common.expectsError
PR-URL: #19514 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent acc328e commit 3e0d40d

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

test/common/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ Indicates if there is more than 1gb of total memory.
8686
regular expression must match the `message` property of the expected error.
8787
* `name` [&lt;string>]
8888
expected error must have this value for its `name` property.
89+
* `info` &lt;Object> expected error must have the same `info` property
90+
that is deeply equal to this value.
8991
* `generatedMessage` [&lt;string>]
9092
(`AssertionError` only) expected error must have this value for its
9193
`generatedMessage` property.

test/common/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,9 @@ exports.expectsError = function expectsError(fn, settings, exact) {
704704
}
705705
assert.strictEqual(typeName, type.name);
706706
}
707+
if ('info' in settings) {
708+
assert.deepStrictEqual(error.info, settings.info);
709+
}
707710
if ('message' in settings) {
708711
const message = settings.message;
709712
if (typeof message === 'string') {
@@ -717,7 +720,7 @@ exports.expectsError = function expectsError(fn, settings, exact) {
717720
// Check all error properties.
718721
const keys = Object.keys(settings);
719722
for (const key of keys) {
720-
if (key === 'message' || key === 'type')
723+
if (key === 'message' || key === 'type' || key === 'info')
721724
continue;
722725
const actual = error[key];
723726
const expected = settings[key];

0 commit comments

Comments
 (0)