Skip to content

Conversation

@markgmilner
Copy link

Related issues:

Description

Adds a new allow_mocked recorder option.

If true, the recorder will only record unmatched requests. Calls to matched requests will return the mocked response and will not be recorded.

This is useful when you want your tests to use specific responses for certain requests but to record the rest.

@HartS
Copy link

HartS commented Apr 22, 2023

This sounds useful! Looking forward to it

@sdotson
Copy link

sdotson commented Jul 27, 2023

what needs to happen for this to get reviewed/merged?

My use case: Make it a lot more visible to engineers that un-mocked network requests are happening, even in files that have some mocked requests already. The goal would be to get that number down to zero in unit tests.

@irfan798
Copy link

The problem with this is its using matchOrigin which doesnt check body beforehand. It assumes that there is a mock but then throws an error when it can't match body later.

So it mistakenly forwards to mocked request instead of sending it to internet and recording it.

https://github.com/ava-labs/nock/blob/allow_mocked/lib/recorder.js#L246

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants