@@ -12,14 +12,9 @@ The API for the `assert` module is [Locked][]. This means that there will be no
1212additions or changes to any of the methods implemented and exposed by
1313the module.
1414
15- ## assert(value[ , message] ), assert.ok(value [ , message ] )
15+ ## assert(value[ , message] )
1616
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() ` ] [ ] .
2318
2419``` js
2520const assert = require (' assert' );
@@ -32,15 +27,6 @@ assert(0);
3227 // throws "AssertionError: 0 == true"
3328assert (false , ' it\' s false' );
3429 // 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"
4430```
4531
4632## assert.deepEqual(actual, expected[ , message] )
@@ -329,6 +315,28 @@ If the values are strictly equal, an `AssertionError` is thrown with a
329315` message ` property set equal to the value of the ` message ` parameter. If the
330316` message ` parameter is undefined, a default error message is assigned.
331317
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+
332340## assert.strictEqual(actual, expected[ , message] )
333341
334342Tests strict equality as determined by the strict equality operator ( ` === ` ).
@@ -396,6 +404,7 @@ assert.throws(
396404[ Locked ] : documentation.html#documentation_stability_index
397405[ `assert.deepEqual` ] : #assert_assert_deepequal_actual_expected_message
398406[ `assert.deepStrictEqual` ] : #assert_assert_deepstrictequal_actual_expected_message
407+ [ `assert.ok()` ] : #assert_assert_ok_value_message
399408[ `assert.throws()` ] : #assert_assert_throws_block_error_message
400409[ `Error` ] : errors.html#errors_class_error
401410[ `RegExp` ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
0 commit comments