diff --git a/test/common/README.md b/test/common/README.md index 765ebe01231..981e27a26b2 100644 --- a/test/common/README.md +++ b/test/common/README.md @@ -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. diff --git a/test/common/index.js b/test/common/index.js index 4c4f0342f2f..ba53065ef01 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -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];