From 937afcc3656d4867af11e188c23533d89ed9bf80 Mon Sep 17 00:00:00 2001 From: estrada9166 Date: Sun, 23 Jun 2019 22:55:32 -0500 Subject: [PATCH] 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 Reviewed-By: James M Snell Reviewed-By: Rich Trott Reviewed-By: Trivikram Kamat --- test/parallel/test-assert.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js index ddf5658af9e45d..04f7571a9bee66 100644 --- a/test/parallel/test-assert.js +++ b/test/parallel/test-assert.js @@ -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;