summaryrefslogtreecommitdiff
path: root/doc/api/assert.md
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2018-01-23 14:38:34 +0100
committerRuben Bridgewater <ruben@bridgewater.de>2018-02-01 09:21:38 +0100
commit3cd7977a425d4ef6d2e9b6d535763bc5633789bf (patch)
treece25cbe676cd9143fd8658469ab53a0283c1ae26 /doc/api/assert.md
parent776f6cdfc4d7f8b3e0eaff6bd71571ebd937609b (diff)
downloadandroid-node-v8-3cd7977a425d4ef6d2e9b6d535763bc5633789bf.tar.gz
android-node-v8-3cd7977a425d4ef6d2e9b6d535763bc5633789bf.tar.bz2
android-node-v8-3cd7977a425d4ef6d2e9b6d535763bc5633789bf.zip
assert: use a default message in assert
In case no arguments are passed to `assert.ok` it should just use a default message. Otherwise `assert.ok` can not be used as a callback. PR-URL: https://github.com/nodejs/node/pull/18319 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Weijia Wang <starkwang@126.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Diffstat (limited to 'doc/api/assert.md')
-rw-r--r--doc/api/assert.md11
1 files changed, 8 insertions, 3 deletions
diff --git a/doc/api/assert.md b/doc/api/assert.md
index 04f312aa66..09ea4483d1 100644
--- a/doc/api/assert.md
+++ b/doc/api/assert.md
@@ -692,9 +692,8 @@ parameter is an instance of an [`Error`][] then it will be thrown instead of the
added: v0.1.21
changes:
- version: REPLACEME
- pr-url: https://github.com/nodejs/node/pull/17581
- description: assert.ok() will throw a `ERR_MISSING_ARGS` error.
- Use assert.fail() instead.
+ pr-url: https://github.com/nodejs/node/pull/REPLACEME
+ description: assert.ok() (no arguments) will now use a predefined error msg.
-->
* `value` {any}
* `message` {any}
@@ -707,6 +706,8 @@ property set equal to the value of the `message` parameter. If the `message`
parameter is `undefined`, a default error message is assigned. If the `message`
parameter is an instance of an [`Error`][] then it will be thrown instead of the
`AssertionError`.
+If no arguments are passed in at all `message` will be set to the string:
+"No value argument passed to assert.ok".
Be aware that in the `repl` the error message will be different to the one
thrown in a file! See below for further details.
@@ -719,6 +720,10 @@ assert.ok(true);
assert.ok(1);
// OK
+assert.ok();
+// throws:
+// "AssertionError: No value argument passed to `assert.ok`.
+
assert.ok(false, 'it\'s false');
// throws "AssertionError: it's false"