Skip to content

Commit

Permalink
test: add tests to assert.ok and improve coverage
Browse files Browse the repository at this point in the history
Refs: https://coverage.nodejs.org/coverage-1a4f27ae21698d0c/lib/assert.js.html#L364

PR-URL: #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>
  • Loading branch information
estrada9166 authored and targos committed Jul 2, 2019
1 parent fd4d1e2 commit 004d26d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/parallel/test-assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 004d26d

Please sign in to comment.