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 <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Evan Lucas <[email protected]>
  • 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
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 f38be41

Please sign in to comment.