test: add info option to common.expectsError
PR-URL: https://github.com/nodejs/node/pull/19514 Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
parent
acc328ef58
commit
3e0d40d4af
@ -86,6 +86,8 @@ Indicates if there is more than 1gb of total memory.
|
||||
regular expression must match the `message` property of the expected error.
|
||||
* `name` [<string>]
|
||||
expected error must have this value for its `name` property.
|
||||
* `info` <Object> expected error must have the same `info` property
|
||||
that is deeply equal to this value.
|
||||
* `generatedMessage` [<string>]
|
||||
(`AssertionError` only) expected error must have this value for its
|
||||
`generatedMessage` property.
|
||||
|
@ -704,6 +704,9 @@ exports.expectsError = function expectsError(fn, settings, exact) {
|
||||
}
|
||||
assert.strictEqual(typeName, type.name);
|
||||
}
|
||||
if ('info' in settings) {
|
||||
assert.deepStrictEqual(error.info, settings.info);
|
||||
}
|
||||
if ('message' in settings) {
|
||||
const message = settings.message;
|
||||
if (typeof message === 'string') {
|
||||
@ -717,7 +720,7 @@ exports.expectsError = function expectsError(fn, settings, exact) {
|
||||
// Check all error properties.
|
||||
const keys = Object.keys(settings);
|
||||
for (const key of keys) {
|
||||
if (key === 'message' || key === 'type')
|
||||
if (key === 'message' || key === 'type' || key === 'info')
|
||||
continue;
|
||||
const actual = error[key];
|
||||
const expected = settings[key];
|
||||
|
Loading…
x
Reference in New Issue
Block a user