doc: argument types for assert methods
Refs: https://github.com/nodejs/node/issues/9399 PR-URL: https://github.com/nodejs/node/pull/11548 Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
893632ec07
commit
76a3e4984c
@ -9,6 +9,8 @@ test invariants.
|
||||
<!-- YAML
|
||||
added: v0.5.9
|
||||
-->
|
||||
* `value` {any}
|
||||
* `message` {any}
|
||||
|
||||
An alias of [`assert.ok()`][] .
|
||||
|
||||
@ -41,6 +43,9 @@ changes:
|
||||
pr-url: https://github.com/nodejs/node/pull/5910
|
||||
description: Handle non-`Uint8Array` typed arrays correctly.
|
||||
-->
|
||||
* `actual` {any}
|
||||
* `expected` {any}
|
||||
* `message` {any}
|
||||
|
||||
Tests for deep equality between the `actual` and `expected` parameters.
|
||||
Primitive values are compared with the [Abstract Equality Comparison][]
|
||||
@ -116,6 +121,9 @@ changes:
|
||||
pr-url: https://github.com/nodejs/node/pull/5910
|
||||
description: Handle non-`Uint8Array` typed arrays correctly.
|
||||
-->
|
||||
* `actual` {any}
|
||||
* `expected` {any}
|
||||
* `message` {any}
|
||||
|
||||
Generally identical to `assert.deepEqual()` with two exceptions:
|
||||
|
||||
@ -150,6 +158,9 @@ changes:
|
||||
pr-url: https://github.com/nodejs/node/pull/3276
|
||||
description: The `error` parameter can now be an arrow function.
|
||||
-->
|
||||
* `block` {Function}
|
||||
* `error` {RegExp|Function}
|
||||
* `message` {any}
|
||||
|
||||
Asserts that the function `block` does not throw an error. See
|
||||
[`assert.throws()`][] for more details.
|
||||
@ -205,6 +216,9 @@ assert.doesNotThrow(
|
||||
<!-- YAML
|
||||
added: v0.1.21
|
||||
-->
|
||||
* `actual` {any}
|
||||
* `expected` {any}
|
||||
* `message` {any}
|
||||
|
||||
Tests shallow, coercive equality between the `actual` and `expected` parameters
|
||||
using the [Abstract Equality Comparison][] ( `==` ).
|
||||
@ -231,6 +245,10 @@ parameter is undefined, a default error message is assigned.
|
||||
<!-- YAML
|
||||
added: v0.1.21
|
||||
-->
|
||||
* `actual` {any}
|
||||
* `expected` {any}
|
||||
* `message` {any}
|
||||
* `operator` {String}
|
||||
|
||||
Throws an `AssertionError`. If `message` is falsy, the error message is set as
|
||||
the values of `actual` and `expected` separated by the provided `operator`.
|
||||
@ -250,6 +268,7 @@ assert.fail(1, 2, 'whoops', '>');
|
||||
<!-- YAML
|
||||
added: v0.1.97
|
||||
-->
|
||||
* `value` {any}
|
||||
|
||||
Throws `value` if `value` is truthy. This is useful when testing the `error`
|
||||
argument in callbacks.
|
||||
@ -271,6 +290,9 @@ assert.ifError(new Error());
|
||||
<!-- YAML
|
||||
added: v0.1.21
|
||||
-->
|
||||
* `actual` {any}
|
||||
* `expected` {any}
|
||||
* `message` {any}
|
||||
|
||||
Tests for any deep inequality. Opposite of [`assert.deepEqual()`][].
|
||||
|
||||
@ -315,6 +337,9 @@ parameter is undefined, a default error message is assigned.
|
||||
<!-- YAML
|
||||
added: v1.2.0
|
||||
-->
|
||||
* `actual` {any}
|
||||
* `expected` {any}
|
||||
* `message` {any}
|
||||
|
||||
Tests for deep strict inequality. Opposite of [`assert.deepStrictEqual()`][].
|
||||
|
||||
@ -336,6 +361,9 @@ the `message` parameter is undefined, a default error message is assigned.
|
||||
<!-- YAML
|
||||
added: v0.1.21
|
||||
-->
|
||||
* `actual` {any}
|
||||
* `expected` {any}
|
||||
* `message` {any}
|
||||
|
||||
Tests shallow, coercive inequality with the [Abstract Equality Comparison][]
|
||||
( `!=` ).
|
||||
@ -361,6 +389,9 @@ parameter is undefined, a default error message is assigned.
|
||||
<!-- YAML
|
||||
added: v0.1.21
|
||||
-->
|
||||
* `actual` {any}
|
||||
* `expected` {any}
|
||||
* `message` {any}
|
||||
|
||||
Tests strict inequality as determined by the [Strict Equality Comparison][]
|
||||
( `!==` ).
|
||||
@ -386,6 +417,8 @@ If the values are strictly equal, an `AssertionError` is thrown with a
|
||||
<!-- YAML
|
||||
added: v0.1.21
|
||||
-->
|
||||
* `value` {any}
|
||||
* `message` {any}
|
||||
|
||||
Tests if `value` is truthy. It is equivalent to
|
||||
`assert.equal(!!value, true, message)`.
|
||||
@ -413,6 +446,9 @@ assert.ok(false, 'it\'s false');
|
||||
<!-- YAML
|
||||
added: v0.1.21
|
||||
-->
|
||||
* `actual` {any}
|
||||
* `expected` {any}
|
||||
* `message` {any}
|
||||
|
||||
Tests strict equality as determined by the [Strict Equality Comparison][]
|
||||
( `===` ).
|
||||
@ -442,6 +478,9 @@ changes:
|
||||
pr-url: https://github.com/nodejs/node/pull/3276
|
||||
description: The `error` parameter can now be an arrow function.
|
||||
-->
|
||||
* `block` {Function}
|
||||
* `error` {RegExp|Function}
|
||||
* `message` {any}
|
||||
|
||||
Expects the function `block` to throw an error.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user