Skip to content

Commit

Permalink
doc: argument types for assert methods
Browse files Browse the repository at this point in the history
Refs: #9399

PR-URL: #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>
  • Loading branch information
ameliavoncat authored and MylesBorins committed Mar 9, 2017
1 parent 53f2848 commit 09c9105
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions doc/api/assert.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ the module.
<!-- YAML
added: v0.5.9
-->
* `value` {any}
* `message` {any}

An alias of [`assert.ok()`][] .

Expand All @@ -36,6 +38,9 @@ assert(false, 'it\'s false');
<!-- YAML
added: v0.1.21
-->
* `actual` {any}
* `expected` {any}
* `message` {any}

Tests for deep equality between the `actual` and `expected` parameters.
Primitive values are compared with the equal comparison operator ( `==` ).
Expand Down Expand Up @@ -97,6 +102,9 @@ parameter is undefined, a default error message is assigned.
<!-- YAML
added: v1.2.0
-->
* `actual` {any}
* `expected` {any}
* `message` {any}

Generally identical to `assert.deepEqual()` with two exceptions. First,
primitive values are compared using the strict equality operator ( `===` ).
Expand All @@ -121,6 +129,9 @@ parameter is undefined, a default error message is assigned.
<!-- YAML
added: v0.1.21
-->
* `block` {Function}
* `error` {RegExp|Function}
* `message` {any}

Asserts that the function `block` does not throw an error. See
[`assert.throws()`][] for more details.
Expand Down Expand Up @@ -176,6 +187,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 equal comparison operator ( `==` ).
Expand All @@ -202,6 +216,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`.
Expand All @@ -221,6 +239,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.
Expand All @@ -238,6 +257,9 @@ assert.ifError(new Error()); // Throws Error
<!-- YAML
added: v0.1.21
-->
* `actual` {any}
* `expected` {any}
* `message` {any}

Tests for any deep inequality. Opposite of [`assert.deepEqual()`][].

Expand Down Expand Up @@ -282,6 +304,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()`][].

Expand All @@ -303,6 +328,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 not equal comparison operator
( `!=` ).
Expand All @@ -328,6 +356,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 not equal operator
( `!==` ).
Expand All @@ -353,6 +384,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)`.
Expand All @@ -378,6 +411,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 operator ( `===` ).

Expand All @@ -402,6 +438,9 @@ If the values are not strictly equal, an `AssertionError` is thrown with a
<!-- YAML
added: v0.1.21
-->
* `block` {Function}
* `error` {RegExp|Function}
* `message` {any}

Expects the function `block` to throw an error.

Expand Down

0 comments on commit 09c9105

Please sign in to comment.