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:
Ruben Bridgewater
2017-12-11 05:04:17 -02:00
parent da5c7d68cd
commit fe257ac207

View File

@@ -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$/
);
```