-
-
Notifications
You must be signed in to change notification settings - Fork 734
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
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
- Loading branch information
Showing
3 changed files
with
25 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters