From fe257ac2078676012ed6d188e63e50827fe69d27 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. 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 7ad56accc28a04..43c7e8e2d429c8 100644 --- a/doc/api/assert.md +++ b/doc/api/assert.md @@ -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$/ ); ```