Skip to content

Commit 7457093

Browse files
BridgeARMylesBorins
authored andcommitted
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. Backport-PR-URL: #19230 PR-URL: #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>
1 parent 612ba1a commit 7457093

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

doc/api/assert.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -738,12 +738,15 @@ assert.throws(
738738

739739
Validate error message using [`RegExp`][]:
740740

741+
Using a regular expression runs `.toString` on the error object, and will
742+
therefore also include the error name.
743+
741744
```js
742745
assert.throws(
743746
() => {
744747
throw new Error('Wrong value');
745748
},
746-
/value/
749+
/^Error: Wrong value$/
747750
);
748751
```
749752

0 commit comments

Comments
 (0)