Skip to content
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

Merged
merged 2 commits into from
Jun 25, 2023

Commits on Jun 23, 2023

  1. 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
    mikicho committed Jun 23, 2023
    Configuration menu
    Copy the full SHA
    e36fab2 View commit details
    Browse the repository at this point in the history

Commits on Jun 25, 2023

  1. style: prettier

    gr2m committed Jun 25, 2023
    Configuration menu
    Copy the full SHA
    1e19df0 View commit details
    Browse the repository at this point in the history