@@ -12,14 +12,9 @@ The API for the `assert` module is [Locked][]. This means that there will be no
12
12
additions or changes to any of the methods implemented and exposed by
13
13
the module.
14
14
15
- ## assert(value[ , message] ), assert.ok(value [ , message ] )
15
+ ## assert(value[ , message] )
16
16
17
- Tests if ` value ` is truthy. It is equivalent to
18
- ` assert.equal(!!value, true, message) ` .
19
-
20
- If ` value ` is not truthy, an ` AssertionError ` is thrown with a ` message `
21
- property set equal to the value of the ` message ` parameter. If the ` message `
22
- parameter is ` undefined ` , a default error message is assigned.
17
+ An alias of [ ` assert.ok() ` ] [ ] .
23
18
24
19
``` js
25
20
const assert = require (' assert' );
@@ -32,15 +27,6 @@ assert(0);
32
27
// throws "AssertionError: 0 == true"
33
28
assert (false , ' it\' s false' );
34
29
// throws "AssertionError: it's false"
35
-
36
- assert .ok (true ); // OK
37
- assert .ok (1 ); // OK
38
- assert .ok (false );
39
- // throws "AssertionError: false == true"
40
- assert .ok (0 );
41
- // throws "AssertionError: 0 == true"
42
- assert .ok (false , ' it\' s false' );
43
- // throws "AssertionError: it's false"
44
30
```
45
31
46
32
## assert.deepEqual(actual, expected[ , message] )
@@ -329,6 +315,28 @@ If the values are strictly equal, an `AssertionError` is thrown with a
329
315
` message ` property set equal to the value of the ` message ` parameter. If the
330
316
` message ` parameter is undefined, a default error message is assigned.
331
317
318
+ ## assert.ok(value[ , message] )
319
+
320
+ Tests if ` value ` is truthy. It is equivalent to
321
+ ` assert.equal(!!value, true, message) ` .
322
+
323
+ If ` value ` is not truthy, an ` AssertionError ` is thrown with a ` message `
324
+ property set equal to the value of the ` message ` parameter. If the ` message `
325
+ parameter is ` undefined ` , a default error message is assigned.
326
+
327
+ ``` js
328
+ const assert = require (' assert' );
329
+
330
+ assert .ok (true ); // OK
331
+ assert .ok (1 ); // OK
332
+ assert .ok (false );
333
+ // throws "AssertionError: false == true"
334
+ assert .ok (0 );
335
+ // throws "AssertionError: 0 == true"
336
+ assert .ok (false , ' it\' s false' );
337
+ // throws "AssertionError: it's false"
338
+ ```
339
+
332
340
## assert.strictEqual(actual, expected[ , message] )
333
341
334
342
Tests strict equality as determined by the strict equality operator ( ` === ` ).
@@ -396,6 +404,7 @@ assert.throws(
396
404
[ Locked ] : documentation.html#documentation_stability_index
397
405
[ `assert.deepEqual` ] : #assert_assert_deepequal_actual_expected_message
398
406
[ `assert.deepStrictEqual` ] : #assert_assert_deepstrictequal_actual_expected_message
407
+ [ `assert.ok()` ] : #assert_assert_ok_value_message
399
408
[ `assert.throws()` ] : #assert_assert_throws_block_error_message
400
409
[ `Error` ] : errors.html#errors_class_error
401
410
[ `RegExp` ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
0 commit comments