Skip to content

Commit

Permalink
Use error constructor to check for ParseError
Browse files Browse the repository at this point in the history
Since we're dealing with a custom error constructor `t.throws` has a
hard time checking the instance is the one we expect. This commit
changes checking to use the constructor error property instead.
  • Loading branch information
alextes committed Mar 8, 2017
1 parent 39bf828 commit 22b76aa
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion test/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ test('catches errors on invalid non-200 responses', async t => {
});

test('should have statusCode in err', async t => {
const err = await t.throws(got(`${s.url}/non200-invalid`, {json: true}), got.ParseError);
const err = await t.throws(got(`${s.url}/non200-invalid`, {json: true}));
t.is(err.constructor, new got.ParseError(new Error(), 500, {}, '').constructor);
t.is(err.statusCode, 500);
});

Expand Down

0 comments on commit 22b76aa

Please sign in to comment.