Skip to content

Commit ab735d0

Browse files
MadLittleModscodebytere
authored andcommittedMar 30, 2020
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: #31271 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent 06bc2de commit ab735d0

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
 

‎doc/api/assert.md

+15
Original file line numberDiff line numberDiff line change
@@ -1111,6 +1111,21 @@ if the `asyncFn` fails to reject.
11111111
})();
11121112
```
11131113

1114+
```js
1115+
(async () => {
1116+
await assert.rejects(
1117+
async () => {
1118+
throw new TypeError('Wrong value');
1119+
},
1120+
(err) => {
1121+
assert.strictEqual(err.name, 'TypeError');
1122+
assert.strictEqual(err.message, 'Wrong value');
1123+
return true;
1124+
}
1125+
);
1126+
})();
1127+
```
1128+
11141129
```js
11151130
assert.rejects(
11161131
Promise.reject(new Error('Wrong value')),

0 commit comments

Comments
 (0)
Please sign in to comment.