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 <[email protected]>
Reviewed-By: Richard Lau <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
Trott authored and targos committed Apr 2, 2018
1 parent 2f09ee7 commit 806bc0d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions test/parallel/test-http-parser.js
Original file line number Diff line number Diff line change
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 806bc0d

Please sign in to comment.