First, thanks for your great module, very helpful for most of my test use cases.
That said, I've found a use case that is not easy to test using the current state of this module. This is when fetch return an error status. Right now, jest-fetch-mock always resolve the Promise even when we mock an error status (> 400)
This pull request try to fix that by rejecting any request that have an init AND a status of 400 or higher.
Now you can do:
fetch.mockResponse(JSON.stringify({}), { status: 404, statusText: "404 Not Found" })
and it will end in the .catch(error) {} block of your tested fetch request
Hi there!
First, thanks for your great module, very helpful for most of my test use cases.
That said, I've found a use case that is not easy to test using the current state of this module. This is when fetch return an error status. Right now, jest-fetch-mock always resolve the Promise even when we mock an error status (> 400) This pull request try to fix that by rejecting any request that have an init AND a status of 400 or higher.
Now you can do:
and it will end in the
.catch(error) {}
block of your tested fetch requestHope this helps!