From 745709396c04d1d12bfc1c2a1c3e7b21bab8911d Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Mon, 11 Dec 2017 05:04:17 -0200 Subject: [PATCH] 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: https://github.com/nodejs/node/pull/19230 PR-URL: https://github.com/nodejs/node/pull/17585 Reviewed-By: Rich Trott Reviewed-By: Benjamin Gruenbaum Reviewed-By: Matteo Collina Reviewed-By: James M Snell Reviewed-By: Gireesh Punathil Reviewed-By: Evan Lucas --- doc/api/assert.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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$/ ); ```