-
-
Notifications
You must be signed in to change notification settings - Fork 734
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
Push persisted interceptors to the end instead of ignore on remove #2350
Conversation
Trying my luck. |
Just to check, swapping the lines around works, but you can't do it because you call the As long as no other tests break and you update docs, I'd be happy to help get it landed. Sorry for the late response |
Cool! I'll add relevant tests. |
Currently, if you do: ``` nock(..).get('/').reply(200).persist(); nock(..).get('/').reply(400); // this will never get called ``` The second interceptor won't get called ever. But sometimes in tests (queue for examples), I want to do: ``` beforeAll(() => { // some default behaviour nock(..).get('/').reply(200).persist(); }); test('should ...', () => { // test specific scenario for this same endpoint above nock(..).get('/').reply(400) }) ``` I find a workaround using the body matcher function: ``` const createInterceptor = () => { nock(..).get('/', () => { createInterceptor(); return true; }) .reply(200) } ``` Which mimics the wanted behavior but is slower and way less elegant. fix
@gr2m PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you so much 💐
🎉 This PR is included in version 13.3.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Currently, if you do:
The second interceptor won't get called ever.
But sometimes in tests (queue for examples), I want to do:
I find a workaround using the body matcher function:
Which pushes the interceptor to the end of the queue (
interceptors
array) and mimics the wanted behavior but is slower and way less elegant.P.S: I'll add tests and documentation if we agree on the wanted behavior.