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 <[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]>
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

Lines changed: 4 additions & 1 deletion
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)