From 004d26d5a5eac18764125ee16af0d7496b1c832d Mon Sep 17 00:00:00 2001 From: estrada9166 Date: Fri, 21 Jun 2019 16:55:38 -0500 Subject: [PATCH] test: add tests to assert.ok and improve coverage Refs: https://coverage.nodejs.org/coverage-1a4f27ae21698d0c/lib/assert.js.html#L364 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 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js index 657b8b9c1bf8d7..ddf5658af9e45d 100644 --- a/test/parallel/test-assert.js +++ b/test/parallel/test-assert.js @@ -44,6 +44,19 @@ assert.ok(a.AssertionError.prototype instanceof Error, assert.throws(() => a(false), a.AssertionError, 'ok(false)'); assert.throws(() => a.ok(false), a.AssertionError, 'ok(false)'); +// Throw message if the message is instanceof Error. +{ + let threw = false; + try { + assert.ok(false, new Error('ok(false)')); + } catch (e) { + threw = true; + assert.ok(e instanceof Error); + } + assert.ok(threw, 'Error: ok(false)'); +} + + a(true); a('test', 'ok(\'test\')'); a.ok(true);