mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
doc: improve .throws RegExp info
It was not clear why the error name is actually also tested for when using a regular expression. This is now clarified. PR-URL: https://github.com/nodejs/node/pull/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>
This commit is contained in:
@@ -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$/
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user