Skip to content

Commit

Permalink
test: fix assert.throws error in test-http-parser
Browse files Browse the repository at this point in the history
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: #19626
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
Trott committed Mar 29, 2018
1 parent ffe3f9a commit 42d1d72
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions test/parallel/test-http-parser.js
Expand Up @@ -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' }
);
}


Expand Down

0 comments on commit 42d1d72

Please sign in to comment.