From 3e0d40d4af6f437ecacb8b54d0d84ed0e5a4899f Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Wed, 21 Mar 2018 01:19:05 +0800 Subject: [PATCH] test: add info option to common.expectsError MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/19514 Reviewed-By: Michaƫl Zasso Reviewed-By: James M Snell --- test/common/README.md | 2 ++ test/common/index.js | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) 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];