| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e5cdfb0 commit c1c78ca
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -400,19 +400,19 @@ parameter is undefined, a default error message is assigned. If the `message` | |||
| 400 | 400 | parameter is an instance of an [`Error`][] then it will be thrown instead of the | |
| 401 | 401 | `AssertionError`. | |
| 402 | 402 | ||
| 403 | - ## assert.doesNotReject(block[, error][, message]) | ||
| 403 | + ## assert.doesNotReject(asyncFn[, error][, message]) | ||
| 404 | 404 | <!-- YAML | |
| 405 | 405 | added: v10.0.0 | |
| 406 | 406 | --> | |
| 407 | - * `block` {Function|Promise} | ||
| 407 | + * `asyncFn` {Function|Promise} | ||
| 408 | 408 | * `error` {RegExp|Function} | |
| 409 | - * `message` {string|Error} | ||
| 409 | + * `message` {string} | ||
| 410 | 410 | ||
| 411 | - Awaits the `block` promise or, if `block` is a function, immediately calls the | ||
| 412 | - function and awaits the returned promise to complete. It will then check that | ||
| 413 | - the promise is not rejected. | ||
| 411 | + Awaits the `asyncFn` promise or, if `asyncFn` is a function, immediately | ||
| 412 | + calls the function and awaits the returned promise to complete. It will then | ||
| 413 | + check that the promise is not rejected. | ||
| 414 | 414 | ||
| 415 | - If `block` is a function and it throws an error synchronously, | ||
| 415 | + If `asyncFn` is a function and it throws an error synchronously, | ||
| 416 | 416 | `assert.doesNotReject()` will return a rejected `Promise` with that error. If | |
| 417 | 417 | the function does not return a promise, `assert.doesNotReject()` will return a | |
| 418 | 418 | rejected `Promise` with an [`ERR_INVALID_RETURN_VALUE`][] error. In both cases | |
@@ -447,7 +447,7 @@ assert.doesNotReject(Promise.reject(new TypeError('Wrong value'))) | |||
| 447 | 447 | }); | |
| 448 | 448 | ``` | |
| 449 | 449 | ||
| 450 | - ## assert.doesNotThrow(block[, error][, message]) | ||
| 450 | + ## assert.doesNotThrow(fn[, error][, message]) | ||
| 451 | 451 | <!-- YAML | |
| 452 | 452 | added: v0.1.21 | |
| 453 | 453 | changes: | |
@@ -458,18 +458,18 @@ changes: | |||
| 458 | 458 | pr-url: https://github.com/nodejs/node/pull/3276 | |
| 459 | 459 | description: The `error` parameter can now be an arrow function. | |
| 460 | 460 | --> | |
| 461 | - * `block` {Function} | ||
| 461 | + * `fn` {Function} | ||
| 462 | 462 | * `error` {RegExp|Function} | |
| 463 | - * `message` {string|Error} | ||
| 463 | + * `message` {string} | ||
| 464 | 464 | ||
| 465 | - Asserts that the function `block` does not throw an error. | ||
| 465 | + Asserts that the function `fn` does not throw an error. | ||
| 466 | 466 | ||
| 467 | 467 | Please note: Using `assert.doesNotThrow()` is actually not useful because there | |
| 468 | 468 | is no benefit by catching an error and then rethrowing it. Instead, consider | |
| 469 | 469 | adding a comment next to the specific code path that should not throw and keep | |
| 470 | 470 | error messages as expressive as possible. | |
| 471 | 471 | ||
| 472 | - When `assert.doesNotThrow()` is called, it will immediately call the `block` | ||
| 472 | + When `assert.doesNotThrow()` is called, it will immediately call the `fn` | ||
| 473 | 473 | function. | |
| 474 | 474 | ||
| 475 | 475 | If an error is thrown and it is the same type as that specified by the `error` | |
@@ -954,19 +954,19 @@ assert(0); | |||
| 954 | 954 | // assert(0) | |
| 955 | 955 | ``` | |
| 956 | 956 | ||
| 957 | - ## assert.rejects(block[, error][, message]) | ||
| 957 | + ## assert.rejects(asyncFn[, error][, message]) | ||
| 958 | 958 | <!-- YAML | |
| 959 | 959 | added: v10.0.0 | |
| 960 | 960 | --> | |
| 961 | - * `block` {Function|Promise} | ||
| 961 | + * `asyncFn` {Function|Promise} | ||
| 962 | 962 | * `error` {RegExp|Function|Object|Error} | |
| 963 | - * `message` {string|Error} | ||
| 963 | + * `message` {string} | ||
| 964 | 964 | ||
| 965 | - Awaits the `block` promise or, if `block` is a function, immediately calls the | ||
| 966 | - function and awaits the returned promise to complete. It will then check that | ||
| 967 | - the promise is rejected. | ||
| 965 | + Awaits the `asyncFn` promise or, if `asyncFn` is a function, immediately | ||
| 966 | + calls the function and awaits the returned promise to complete. It will then | ||
| 967 | + check that the promise is rejected. | ||
| 968 | 968 | ||
| 969 | - If `block` is a function and it throws an error synchronously, | ||
| 969 | + If `asyncFn` is a function and it throws an error synchronously, | ||
| 970 | 970 | `assert.rejects()` will return a rejected `Promise` with that error. If the | |
| 971 | 971 | function does not return a promise, `assert.rejects()` will return a rejected | |
| 972 | 972 | `Promise` with an [`ERR_INVALID_RETURN_VALUE`][] error. In both cases the error | |
@@ -981,7 +981,7 @@ each property will be tested for including the non-enumerable `message` and | |||
| 981 | 981 | `name` properties. | |
| 982 | 982 | ||
| 983 | 983 | If specified, `message` will be the message provided by the `AssertionError` if | |
| 984 | - the block fails to reject. | ||
| 984 | + the `asyncFn` fails to reject. | ||
| 985 | 985 | ||
| 986 | 986 | ```js | |
| 987 | 987 | (async () => { | |
@@ -1052,7 +1052,7 @@ If the values are not strictly equal, an `AssertionError` is thrown with a | |||
| 1052 | 1052 | `message` parameter is an instance of an [`Error`][] then it will be thrown | |
| 1053 | 1053 | instead of the `AssertionError`. | |
| 1054 | 1054 | ||
| 1055 | - ## assert.throws(block[, error][, message]) | ||
| 1055 | + ## assert.throws(fn[, error][, message]) | ||
| 1056 | 1056 | <!-- YAML | |
| 1057 | 1057 | added: v0.1.21 | |
| 1058 | 1058 | changes: | |
@@ -1067,11 +1067,11 @@ changes: | |||
| 1067 | 1067 | pr-url: https://github.com/nodejs/node/pull/3276 | |
| 1068 | 1068 | description: The `error` parameter can now be an arrow function. | |
| 1069 | 1069 | --> | |
| 1070 | - * `block` {Function} | ||
| 1070 | + * `fn` {Function} | ||
| 1071 | 1071 | * `error` {RegExp|Function|Object|Error} | |
| 1072 | - * `message` {string|Error} | ||
| 1072 | + * `message` {string} | ||
| 1073 | 1073 | ||
| 1074 | - Expects the function `block` to throw an error. | ||
| 1074 | + Expects the function `fn` to throw an error. | ||
| 1075 | 1075 | ||
| 1076 | 1076 | If specified, `error` can be a [`Class`][], [`RegExp`][], a validation function, | |
| 1077 | 1077 | a validation object where each property will be tested for strict deep equality, | |
@@ -1080,8 +1080,9 @@ equality including the non-enumerable `message` and `name` properties. When | |||
| 1080 | 1080 | using an object, it is also possible to use a regular expression, when | |
| 1081 | 1081 | validating against a string property. See below for examples. | |
| 1082 | 1082 | ||
| 1083 | - If specified, `message` will be the message provided by the `AssertionError` if | ||
| 1084 | - the block fails to throw. | ||
| 1083 | + If specified, `message` will be appended to the message provided by the | ||
| 1084 | + `AssertionError` if the `fn` call fails to throw or in case the error validation | ||
| 1085 | + fails. | ||
| 1085 | 1086 | ||
| 1086 | 1087 | Custom validation object/error instance: | |
| 1087 | 1088 | ||
@@ -1246,12 +1247,12 @@ second argument. This might lead to difficult-to-spot errors. | |||
| 1246 | 1247 | [`WeakSet`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet | |
| 1247 | 1248 | [`assert.deepEqual()`]: #assert_assert_deepequal_actual_expected_message | |
| 1248 | 1249 | [`assert.deepStrictEqual()`]: #assert_assert_deepstrictequal_actual_expected_message | |
| 1249 | - [`assert.doesNotThrow()`]: #assert_assert_doesnotthrow_block_error_message | ||
| 1250 | + [`assert.doesNotThrow()`]: #assert_assert_doesnotthrow_fn_error_message | ||
| 1250 | 1251 | [`assert.notDeepStrictEqual()`]: #assert_assert_notdeepstrictequal_actual_expected_message | |
| 1251 | 1252 | [`assert.notStrictEqual()`]: #assert_assert_notstrictequal_actual_expected_message | |
| 1252 | 1253 | [`assert.ok()`]: #assert_assert_ok_value_message | |
| 1253 | 1254 | [`assert.strictEqual()`]: #assert_assert_strictequal_actual_expected_message | |
| 1254 | - [`assert.throws()`]: #assert_assert_throws_block_error_message | ||
| 1255 | + [`assert.throws()`]: #assert_assert_throws_fn_error_message | ||
| 1255 | 1256 | [`strict mode`]: #assert_strict_mode | |
| 1256 | 1257 | [Abstract Equality Comparison]: https://tc39.github.io/ecma262/#sec-abstract-equality-comparison | |
| 1257 | 1258 | [Object.prototype.toString()]: https://tc39.github.io/ecma262/#sec-object.prototype.tostring | |
| Back | FazBrowse Home | New Git URL |
0 commit comments