Background
I would like to use FetchMock and Chai/Mocha to write a unit test for a feature I've written.
I have a wrapper around fetch that causes it to return a response with a (specific) failed code if there's a network failure, instead of rejecting.
The code itself works. I can hand test it by bringing down the wifi on my machine by hand while the code is running.
I have reason to expect this code will be refactored, someday, by someone. So I would like some unit tests around it.
The Question
How do I use Chai/Mocha, and any other tools (like fetchMock which I'm currently using) to create a test around that scenario?
I can't figure out how to fake a network failure from within a unit test.
Aucun commentaire:
Enregistrer un commentaire