Am using Mocha, Chai, Sinon, Proxyquire and Nock.
For this particular test scenario (for which this question is being asked), wish to test the exact same URL several times, each in a separate test that expects a different response.
For example, a response with no merchant feeds, 1 merchant feed, and yet again with 2 merchant feeds.
The existing code all works, furthermore if I run tests individually they pass.
However, if i run them together using Mocha in a single suite they fail. Believe the issue is that Nock hijacks the global http object for a given URL and each test (running asynchronously at the same time) is competing for the same global response reference.
In the scenario above, a response prepared with a canned reply of 1 merchant is getting say overwritten by the setup to respond with 2 merchants etc.
Is there a mechanism to avoid this happening, for instance guarantees around serial execution of async Mocha testcases (which I believed was the default behaviour).