Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: add added: information for assert #6688

Closed
wants to merge 1 commit into from
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
42 changes: 42 additions & 0 deletions doc/api/assert.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ additions or changes to any of the methods implemented and exposed by
the module.

## assert(value[, message])
<!-- YAML
added: v0.5.9
-->

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

Expand All @@ -30,6 +33,9 @@ assert(false, 'it\'s false');
```

## assert.deepEqual(actual, expected[, message])
<!-- YAML
added: v0.1.21
-->

Tests for deep equality between the `actual` and `expected` parameters.
Primitive values are compared with the equal comparison operator ( `==` ).
Expand Down Expand Up @@ -88,6 +94,9 @@ property set equal to the value of the `message` parameter. If the `message`
parameter is undefined, a default error message is assigned.

## assert.deepStrictEqual(actual, expected[, message])
<!-- YAML
added: v1.2.0
-->

Generally identical to `assert.deepEqual()` with two exceptions. First,
primitive values are compared using the strict equality operator ( `===` ).
Expand All @@ -109,6 +118,9 @@ property set equal to the value of the `message` parameter. If the `message`
parameter is undefined, a default error message is assigned.

## assert.doesNotThrow(block[, error][, message])
<!-- YAML
added: v0.1.21
-->

Asserts that the function `block` does not throw an error. See
[`assert.throws()`][] for more details.
Expand Down Expand Up @@ -161,6 +173,9 @@ assert.doesNotThrow(
```

## assert.equal(actual, expected[, message])
<!-- YAML
added: v0.1.21
-->

Tests shallow, coercive equality between the `actual` and `expected` parameters
using the equal comparison operator ( `==` ).
Expand All @@ -184,6 +199,9 @@ property set equal to the value of the `message` parameter. If the `message`
parameter is undefined, a default error message is assigned.

## assert.fail(actual, expected, message, operator)
<!-- YAML
added: v0.1.21
-->

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 @@ -200,6 +218,9 @@ assert.fail(1, 2, 'whoops', '>');
```

## assert.ifError(value)
<!-- YAML
added: v0.1.97
-->

Throws `value` if `value` is truthy. This is useful when testing the `error`
argument in callbacks.
Expand All @@ -214,6 +235,9 @@ assert.ifError(new Error()); // Throws Error
```

## assert.notDeepEqual(actual, expected[, message])
<!-- YAML
added: v0.1.21
-->

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

Expand Down Expand Up @@ -255,6 +279,9 @@ property set equal to the value of the `message` parameter. If the `message`
parameter is undefined, a default error message is assigned.

## assert.notDeepStrictEqual(actual, expected[, message])
<!-- YAML
added: v1.2.0
-->

Tests for deep strict inequality. Opposite of [`assert.deepStrictEqual()`][].

Expand All @@ -273,6 +300,9 @@ with a `message` property set equal to the value of the `message` parameter. If
the `message` parameter is undefined, a default error message is assigned.

## assert.notEqual(actual, expected[, message])
<!-- YAML
added: v0.1.21
-->

Tests shallow, coercive inequality with the not equal comparison operator
( `!=` ).
Expand All @@ -295,6 +325,9 @@ property set equal to the value of the `message` parameter. If the `message`
parameter is undefined, a default error message is assigned.

## assert.notStrictEqual(actual, expected[, message])
<!-- YAML
added: v0.1.21
-->

Tests strict inequality as determined by the strict not equal operator
( `!==` ).
Expand All @@ -317,6 +350,9 @@ If the values are strictly equal, an `AssertionError` is thrown with a
`message` parameter is undefined, a default error message is assigned.

## assert.ok(value[, message])
<!-- YAML
added: v0.1.21
-->

Tests if `value` is truthy. It is equivalent to
`assert.equal(!!value, true, message)`.
Expand All @@ -339,6 +375,9 @@ assert.ok(false, 'it\'s false');
```

## assert.strictEqual(actual, expected[, message])
<!-- YAML
added: v0.1.21
-->

Tests strict equality as determined by the strict equality operator ( `===` ).

Expand All @@ -360,6 +399,9 @@ If the values are not strictly equal, an `AssertionError` is thrown with a
`message` parameter is undefined, a default error message is assigned.

## assert.throws(block[, error][, message])
<!-- YAML
added: v0.1.21
-->

Expects the function `block` to throw an error.

Expand Down