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:
Joyee Cheung 2018-03-21 01:19:05 +08:00
parent acc328ef58
commit 3e0d40d4af
No known key found for this signature in database
GPG Key ID: F586868AAD831D0C
2 changed files with 6 additions and 1 deletions

View File

@ -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` [&lt;string>]
expected error must have this value for its `name` property.
* `info` &lt;Object> expected error must have the same `info` property
that is deeply equal to this value.
* `generatedMessage` [&lt;string>]
(`AssertionError` only) expected error must have this value for its
`generatedMessage` property.

View File

@ -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];