jameslnewell / xhr-mock

Utility for mocking XMLHttpRequest.
196 stars 48 forks source link

Simulating a timeout causes Jest to throw a ECONNREFUSED error but the tests pass #108

Closed radiantshaw closed 3 years ago

radiantshaw commented 3 years ago

I'm simulating a timeout using:

mock.get("/some-url", function() {
  return new Promise(function() {});
});

The tests pass, but Jest throws:

Error: Error: connect ECONNREFUSED 127.0.0.1:80
radiantshaw commented 3 years ago

I was able to fix the issue by resetting the mocks on every test. I suspect that it is because of async examples clashing with each other. Although, not entirely sure what's happening; it's clear that it's not the fault of this package. So closing this issue.