Nock: Record for a given URL only while mocking requests to other domains

Created on 26 Jul 2018  Â·  6Comments  Â·  Source: nock/nock

Is it possible to execute nock.recorder.rec() but only record a specific domain?

sometimes when testing i would like some APIs calls to actually go through but only a given domain to be recorded.

thank you

feature stale

Most helpful comment

You can’t record and intercept at the same time I’m afraid :( When you start recording than the interception gets disabled. But I see how this could be a valid use case, maybe something we could add in future?

All 6 comments

All requests go trough when you are recording. You can filter out the recorded fixtures after you received them. See https://github.com/nock/nock#dont_print-option – does that help?

@gr2m thanks for the reply!

On my case, I would like to let all requests that go to localhost to don't be recorded or intercepted, but the ones going to an external api to be recorded / intercepted.

I still didn't find a way, maybe i need to dig deeper on the readme?

You can’t record and intercept at the same time I’m afraid :( When you start recording than the interception gets disabled. But I see how this could be a valid use case, maybe something we could add in future?

that would be great, like if "recorder.rec()" could take a "domain" or rule so only those would be recorded, this would be sweet!

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. We try to do our best, but nock is maintained by volunteers and there is only so much we can do at a time. Thank you for your contributions.

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue and add a reference to this one if it’s related. Thank you!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

glebsts picture glebsts  Â·  7Comments

jeffcharles picture jeffcharles  Â·  7Comments

cristianszwarc picture cristianszwarc  Â·  6Comments

purefan picture purefan  Â·  3Comments

gr2m picture gr2m  Â·  6Comments