superagent-mocker icon indicating copy to clipboard operation
superagent-mocker copied to clipboard

Mocking an error response

Open spencerfdavis opened this issue 9 years ago • 2 comments

I'm trying to mock a POST call that would return a 401 Unauthorized error for some testing. Any way to do this?

spencerfdavis avatar Dec 17 '15 16:12 spencerfdavis

Can you show your code?

A avatar Dec 17 '15 19:12 A

This works for me:

mock.get(url, (req) => ( {status: 500, body: {error:'batman'}} ))

It would be a good idea to have something in the README, @A

dmwelch avatar Nov 30 '18 21:11 dmwelch