Skip to content

Commit 6e9d795

Browse files
estrada9166addaleax
authored andcommitted
test: add tests to assert.ok and improve coverage
Refs: https://coverage.nodejs.org/coverage-1a4f27ae21698d0c/lib/assert.js.html#L364 PR-URL: #28355 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent 26b048e commit 6e9d795

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test/parallel/test-assert.js

+13
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,19 @@ assert.ok(a.AssertionError.prototype instanceof Error,
4444
assert.throws(() => a(false), a.AssertionError, 'ok(false)');
4545
assert.throws(() => a.ok(false), a.AssertionError, 'ok(false)');
4646

47+
// Throw message if the message is instanceof Error.
48+
{
49+
let threw = false;
50+
try {
51+
assert.ok(false, new Error('ok(false)'));
52+
} catch (e) {
53+
threw = true;
54+
assert.ok(e instanceof Error);
55+
}
56+
assert.ok(threw, 'Error: ok(false)');
57+
}
58+
59+
4760
a(true);
4861
a('test', 'ok(\'test\')');
4962
a.ok(true);

0 commit comments

Comments
 (0)