diff --git a/doc/api/assert.md b/doc/api/assert.md index 1bbb2c1f367027..5e4d0e75f53e60 100644 --- a/doc/api/assert.md +++ b/doc/api/assert.md @@ -738,12 +738,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$/ ); ```