From 4cee226eb41f2c2e3c71800facc0cbaa2f06ecb5 Mon Sep 17 00:00:00 2001 From: iandrc Date: Fri, 24 Jul 2020 01:58:35 +0300 Subject: [PATCH] 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: https://github.com/nodejs/node/issues/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 PR-URL: https://github.com/nodejs/node/pull/34501 Reviewed-By: Anna Henningsen Reviewed-By: Ruben Bridgewater Reviewed-By: Anto Aravinth Reviewed-By: Zeyu Yang --- doc/api/console.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/api/console.md b/doc/api/console.md index db9b3955a56146..a50d09aae87515 100644 --- a/doc/api/console.md +++ b/doc/api/console.md @@ -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. @@ -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`