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.

PR-URL: nodejs#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 committed Mar 8, 2018
1 parent cc52dec commit f38be41
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion doc/api/assert.md
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 f38be41

Please sign in to comment.