Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Eastwood <contact@ericeastwood.com>2020-01-09 10:14:44 +0300
committerRich Trott <rtrott@gmail.com>2020-02-24 14:49:12 +0300
commitbe2f3a3bf88fd728799d1917f7d82428f53183f0 (patch)
tree64ffcdbd2cdcb9df43587ee93e0722aac904a0d2 /doc/api/assert.md
parentdb28739aed31b2ad6e85c497e3a836a29d13021c (diff)
doc: update assert.rejects() docs with a validation function example
Spawned from my own struggle to use in https://gitlab.com/gitlab-org/gitter/webapp/merge_requests/1702#note_268452483 PR-URL: https://github.com/nodejs/node/pull/31271 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'doc/api/assert.md')
-rw-r--r--doc/api/assert.md15
1 files changed, 15 insertions, 0 deletions
diff --git a/doc/api/assert.md b/doc/api/assert.md
index bb9df480ddf..732b4ba8e02 100644
--- a/doc/api/assert.md
+++ b/doc/api/assert.md
@@ -1135,6 +1135,21 @@ if the `asyncFn` fails to reject.
```
```js
+(async () => {
+ await assert.rejects(
+ async () => {
+ throw new TypeError('Wrong value');
+ },
+ (err) => {
+ assert.strictEqual(err.name, 'TypeError');
+ assert.strictEqual(err.message, 'Wrong value');
+ return true;
+ }
+ );
+})();
+```
+
+```js
assert.rejects(
Promise.reject(new Error('Wrong value')),
Error