I am looking for a way to be able to specify which nock request will be called for each mocha test. The issue is that I have ~50 nock request all with the same exact url (post data differs) and it makes using skip()
and only()
in mocha a huge pain. I am thinking of using headers to differentiate. Is there a better option?
Asked
Active
Viewed 849 times
0

cyberwombat
- 38,105
- 35
- 175
- 251
-
You can call `nock()` for the individual test – Explosion Pills Aug 12 '14 at 17:05
-
Ah thanks that set me on right track - had all my mocks in a separate file. – cyberwombat Aug 12 '14 at 17:15
1 Answers
0
If you call nock
for the individual test you can reuse URLs for that test. If it's the same URL you can set it as a variable to save some typing too.
var url = "http://example.com";
it("should test something", function () {
nock(url).post;
});
it("should test another thing", function () {
nock(url).post;
});

Explosion Pills
- 188,624
- 52
- 326
- 405