Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
console: document the behavior of console.assert()
Add a description and an example of console.assert() call with
no arguments. If called like this, the method should output:
"Assertion failed".

Fixes: #34500
Refs: https://nodejs.org/dist/latest-v14.x/docs/api/console.html#console_console_assert_value_message
Refs: https://console.spec.whatwg.org/#assert
  • Loading branch information
iandrc committed Jul 24, 2020
commit 96679f69ce6756d9b16a66d82b3fa87b97449953
3 changes: 3 additions & 0 deletions doc/api/console.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ changes:
* `...message` {any} All arguments besides `value` are used as error message.

A simple assertion test that verifies whether `value` is truthy. If it is not,
or `value` is not passed,
`Assertion failed` is logged. If provided, the error `message` is formatted
using [`util.format()`][] by passing along all message arguments. The output is
used as the error message.
Expand All @@ -162,6 +163,8 @@ console.assert(true, 'does nothing');
// OK
console.assert(false, 'Whoops %s work', 'didn\'t');
// Assertion failed: Whoops didn't work
console.assert();
// Assertion failed
```

Calling `console.assert()` with a falsy assertion will only cause the `message`
Expand Down