@@ -408,19 +408,19 @@ parameter is undefined, a default error message is assigned. If the `message`
408
408
parameter is an instance of an [ ` Error ` ] [ ] then it will be thrown instead of the
409
409
` AssertionError ` .
410
410
411
- ## assert.doesNotReject(block [ , error] [ , message ] )
411
+ ## assert.doesNotReject(asyncFn [ , error] [ , message ] )
412
412
<!-- YAML
413
413
added: v10.0.0
414
414
-->
415
- * ` block ` {Function|Promise}
415
+ * ` asyncFn ` {Function|Promise}
416
416
* ` error ` {RegExp|Function}
417
- * ` message ` {string|Error }
417
+ * ` message ` {string}
418
418
419
- Awaits the ` block ` promise or, if ` block ` is a function, immediately calls the
420
- function and awaits the returned promise to complete. It will then check that
421
- the promise is not rejected.
419
+ Awaits the ` asyncFn ` promise or, if ` asyncFn ` is a function, immediately
420
+ calls the function and awaits the returned promise to complete. It will then
421
+ check that the promise is not rejected.
422
422
423
- If ` block ` is a function and it throws an error synchronously,
423
+ If ` asyncFn ` is a function and it throws an error synchronously,
424
424
` assert.doesNotReject() ` will return a rejected ` Promise ` with that error. If
425
425
the function does not return a promise, ` assert.doesNotReject() ` will return a
426
426
rejected ` Promise ` with an [ ` ERR_INVALID_RETURN_VALUE ` ] [ ] error. In both cases
@@ -455,7 +455,7 @@ assert.doesNotReject(Promise.reject(new TypeError('Wrong value')))
455
455
});
456
456
```
457
457
458
- ## assert.doesNotThrow(block [ , error] [ , message ] )
458
+ ## assert.doesNotThrow(fn [ , error] [ , message ] )
459
459
<!-- YAML
460
460
added: v0.1.21
461
461
changes:
@@ -466,18 +466,18 @@ changes:
466
466
pr-url: https://github.com/nodejs/node/pull/3276
467
467
description: The `error` parameter can now be an arrow function.
468
468
-->
469
- * ` block ` {Function}
469
+ * ` fn ` {Function}
470
470
* ` error ` {RegExp|Function}
471
- * ` message ` {string|Error }
471
+ * ` message ` {string}
472
472
473
- Asserts that the function ` block ` does not throw an error.
473
+ Asserts that the function ` fn ` does not throw an error.
474
474
475
475
Please note: Using ` assert.doesNotThrow() ` is actually not useful because there
476
476
is no benefit by catching an error and then rethrowing it. Instead, consider
477
477
adding a comment next to the specific code path that should not throw and keep
478
478
error messages as expressive as possible.
479
479
480
- When ` assert.doesNotThrow() ` is called, it will immediately call the ` block `
480
+ When ` assert.doesNotThrow() ` is called, it will immediately call the ` fn `
481
481
function.
482
482
483
483
If an error is thrown and it is the same type as that specified by the ` error `
@@ -964,19 +964,19 @@ assert(0);
964
964
// assert(0)
965
965
```
966
966
967
- ## assert.rejects(block [ , error] [ , message ] )
967
+ ## assert.rejects(asyncFn [ , error] [ , message ] )
968
968
<!-- YAML
969
969
added: v10.0.0
970
970
-->
971
- * ` block ` {Function|Promise}
971
+ * ` asyncFn ` {Function|Promise}
972
972
* ` error ` {RegExp|Function|Object|Error}
973
- * ` message ` {string|Error }
973
+ * ` message ` {string}
974
974
975
- Awaits the ` block ` promise or, if ` block ` is a function, immediately calls the
976
- function and awaits the returned promise to complete. It will then check that
977
- the promise is rejected.
975
+ Awaits the ` asyncFn ` promise or, if ` asyncFn ` is a function, immediately
976
+ calls the function and awaits the returned promise to complete. It will then
977
+ check that the promise is rejected.
978
978
979
- If ` block ` is a function and it throws an error synchronously,
979
+ If ` asyncFn ` is a function and it throws an error synchronously,
980
980
` assert.rejects() ` will return a rejected ` Promise ` with that error. If the
981
981
function does not return a promise, ` assert.rejects() ` will return a rejected
982
982
` Promise ` with an [ ` ERR_INVALID_RETURN_VALUE ` ] [ ] error. In both cases the error
@@ -991,7 +991,7 @@ each property will be tested for including the non-enumerable `message` and
991
991
` name ` properties.
992
992
993
993
If specified, ` message ` will be the message provided by the ` AssertionError ` if
994
- the block fails to reject.
994
+ the ` asyncFn ` fails to reject.
995
995
996
996
``` js
997
997
(async () => {
@@ -1063,7 +1063,7 @@ If the values are not strictly equal, an `AssertionError` is thrown with a
1063
1063
` message ` parameter is an instance of an [ ` Error ` ] [ ] then it will be thrown
1064
1064
instead of the ` AssertionError ` .
1065
1065
1066
- ## assert.throws(block [ , error] [ , message ] )
1066
+ ## assert.throws(fn [ , error] [ , message ] )
1067
1067
<!-- YAML
1068
1068
added: v0.1.21
1069
1069
changes:
@@ -1078,11 +1078,11 @@ changes:
1078
1078
pr-url: https://github.com/nodejs/node/pull/3276
1079
1079
description: The `error` parameter can now be an arrow function.
1080
1080
-->
1081
- * ` block ` {Function}
1081
+ * ` fn ` {Function}
1082
1082
* ` error ` {RegExp|Function|Object|Error}
1083
- * ` message ` {string|Error }
1083
+ * ` message ` {string}
1084
1084
1085
- Expects the function ` block ` to throw an error.
1085
+ Expects the function ` fn ` to throw an error.
1086
1086
1087
1087
If specified, ` error ` can be a [ ` Class ` ] [ ] , [ ` RegExp ` ] [ ] , a validation function,
1088
1088
a validation object where each property will be tested for strict deep equality,
@@ -1091,8 +1091,9 @@ equality including the non-enumerable `message` and `name` properties. When
1091
1091
using an object, it is also possible to use a regular expression, when
1092
1092
validating against a string property. See below for examples.
1093
1093
1094
- If specified, ` message ` will be the message provided by the ` AssertionError ` if
1095
- the block fails to throw.
1094
+ If specified, ` message ` will be appended to the message provided by the
1095
+ ` AssertionError ` if the ` fn ` call fails to throw or in case the error validation
1096
+ fails.
1096
1097
1097
1098
Custom validation object/error instance:
1098
1099
@@ -1258,12 +1259,12 @@ second argument. This might lead to difficult-to-spot errors.
1258
1259
[ `WeakSet` ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet
1259
1260
[ `assert.deepEqual()` ] : #assert_assert_deepequal_actual_expected_message
1260
1261
[ `assert.deepStrictEqual()` ] : #assert_assert_deepstrictequal_actual_expected_message
1261
- [ `assert.doesNotThrow()` ] : #assert_assert_doesnotthrow_block_error_message
1262
+ [ `assert.doesNotThrow()` ] : #assert_assert_doesnotthrow_fn_error_message
1262
1263
[ `assert.notDeepStrictEqual()` ] : #assert_assert_notdeepstrictequal_actual_expected_message
1263
1264
[ `assert.notStrictEqual()` ] : #assert_assert_notstrictequal_actual_expected_message
1264
1265
[ `assert.ok()` ] : #assert_assert_ok_value_message
1265
1266
[ `assert.strictEqual()` ] : #assert_assert_strictequal_actual_expected_message
1266
- [ `assert.throws()` ] : #assert_assert_throws_block_error_message
1267
+ [ `assert.throws()` ] : #assert_assert_throws_fn_error_message
1267
1268
[ `strict mode` ] : #assert_strict_mode
1268
1269
[ Abstract Equality Comparison ] : https://tc39.github.io/ecma262/#sec-abstract-equality-comparison
1269
1270
[ Object.prototype.toString() ] : https://tc39.github.io/ecma262/#sec-object.prototype.tostring
0 commit comments