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:
parent
6e9d795642
commit
367ada49f1
@ -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.
|
// Make sure that validating using constructor really works.
|
||||||
{
|
{
|
||||||
let threw = false;
|
let threw = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user