Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Push persisted interceptors to the end instead of ignore on remove (n…
…ock#2350) 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.
- Loading branch information