New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Interceptors not being removed in 13.3.2 #2501
Labels
Comments
a pull request would be very welcome. Ideally we would add a test that would prevent a regression like this from happening again |
2 tasks
Potential duplication: #2353 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please avoid duplicates
Reproducible test case
See description
Nock Version
13.3.2
Node Version
18.17.0
TypeScript Version
5.1.6
What happened?
Interceptors aren't being removed in the same way following #2497. #2500 is also reporting an issue with 13.3.2 but it doesn't mention
removeInterceptor
so I don't believe the issues are the same.We have a file that sets up a bunch of default mock responses using
nock
. In some tests, we needed to remove these usingremoveInterceptor
. Because the interceptors were defined in another file, we couldn't easily pass the interceptor object, so instead we constructed an equivalent one, andremoveInterceptor
behaved as we wanted. When upgrading to 13.3.2 from 13.3.1, this broke.While looking for workarounds, I also noticed that there doesn't seem to be a good way to remove an interceptor with a regex URI by passing a
ReqOptions
object toremoveInterceptor
instead of anInterceptor
:From a brief look at the source and the output of
pendingMocks
for regex interceptors, it seems like it should be possible to convertoptions.key
to a string if it's a regex, and allow removal in this way. Maybe it's more complex than I realise, but it would be a nice feature if not.A final, somewhat tangential point: the link in this prompt from the issue template is still using
nock/nock.js
when I believe it should benock/nock
, so it's a 404:Would you be interested in contributing a fix?
The text was updated successfully, but these errors were encountered: