From 42d1d72a2e8a0ca1ffac98a4fe761e6c42b54c3b Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 26 Mar 2018 21:19:01 -0700 Subject: [PATCH] test: fix assert.throws error in test-http-parser The third argument of `assert.throws()` is a message that is used by the AssertionError, not the message to check in the thrown error. It appears that there is an assert.throws() in test-http-parser that expects the latter behavior. Rewrite the call to check the error message. Even if this wasn't a mistake, this change results in a more robust check. PR-URL: https://github.com/nodejs/node/pull/19626 Reviewed-By: Daniel Bevenius Reviewed-By: Richard Lau Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: Trivikram Kamat Reviewed-By: James M Snell --- test/parallel/test-http-parser.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/parallel/test-http-parser.js b/test/parallel/test-http-parser.js index df3a87f73c8d15..bc9c6920bc36a2 100644 --- a/test/parallel/test-http-parser.js +++ b/test/parallel/test-http-parser.js @@ -97,9 +97,10 @@ function expectBody(expected) { parser.reinitialize(HTTPParser.REQUEST); - assert.throws(function() { - parser.execute(request, 0, request.length); - }, Error, 'hello world'); + assert.throws( + () => { parser.execute(request, 0, request.length); }, + { name: 'Error', message: 'hello world' } + ); }