Skip to content

Commit

Permalink
doc: improve .throws RegExp info
Browse files Browse the repository at this point in the history
It was not clear why the error name is actually also tested for when
using a regular expression. This is now clarified.

Backport-PR-URL: #19230
PR-URL: #17585
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
  • Loading branch information
BridgeAR authored and MylesBorins committed Mar 13, 2018
1 parent 38e5c69 commit c193641
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion doc/api/assert.md
Original file line number Diff line number Diff line change
Expand Up @@ -738,12 +738,15 @@ assert.throws(

Validate error message using [`RegExp`][]:

Using a regular expression runs `.toString` on the error object, and will
therefore also include the error name.

```js
assert.throws(
() => {
throw new Error('Wrong value');
},
/value/
/^Error: Wrong value$/
);
```

Expand Down

0 comments on commit c193641

Please sign in to comment.