0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00

test: add test to doesNotThrow; validate if actual with regex

Refs: https://coverage.nodejs.org/coverage-1a4f27ae21698d0c/lib/assert.js.html#L736

PR-URL: https://github.com/nodejs/node/pull/28355
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
estrada9166 2019-06-23 22:55:32 -05:00 committed by Anna Henningsen
parent 6e9d795642
commit 367ada49f1
No known key found for this signature in database
GPG Key ID: 9C63F3A6CD2AD8F9

View File

@ -178,6 +178,17 @@ assert.throws(
}
);
assert.throws(
() => a.doesNotThrow(() => thrower(Error), /\[[a-z]{6}\s[A-z]{6}\]/g, 'user message'),
{
name: 'AssertionError',
code: 'ERR_ASSERTION',
operator: 'doesNotThrow',
message: 'Got unwanted exception: user message\n' +
'Actual message: "[object Object]"'
}
);
// Make sure that validating using constructor really works.
{
let threw = false;