Closed jonathansp closed 6 years ago
Hmmm... it shouldn't be showing that message if your mock is registered before the request and your request is being matched e.g. https://codesandbox.io/s/n05m1wl1jl
Can you please check the mock is registered before the request is made and that the request URL matches the mock URL e.g. dummy.host/schemas
not http://dummy.host/schemas
The mock is registered before the request is done. I've just realized it only happens when I use jest --watch
.
Are you calling xhrmock.teardown()
after each test? If you already are, can you please provide minimal repository reproducing the problem. Thanks.
In my test case I'm expecting an HTTP error, so I mocked XHR response like this:
How to avoid the follow message to be printed?
https://github.com/jameslnewell/xhr-mock/blob/master/packages/xhr-mock/src/MockXMLHttpRequest.ts#L73