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 Dec 19, 2017
1 parent da5c7d6 commit fe257ac
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 @@ -740,12 +740,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 fe257ac

Please sign in to comment.