Skip to content

Commit

Permalink
test: add info option to common.expectsError
Browse files Browse the repository at this point in the history
PR-URL: nodejs#19514
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
joyeecheung committed Apr 4, 2018
1 parent acc328e commit 3e0d40d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions test/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 4 additions & 1 deletion test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand All @@ -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];
Expand Down

0 comments on commit 3e0d40d

Please sign in to comment.