How to use the nock.removeInterceptor function in nock

To help you get started, we’ve selected a few nock examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nock / nock / types / tests.ts View on Github external
})

// .removeInterceptor()
nock.removeInterceptor({
  hostname: 'localhost',
  path: '/mockedResource',
})
nock.removeInterceptor({
  hostname: 'localhost',
  path: '/login',
  method: 'POST',
  proto: 'https',
})

const interceptor = nock('http://example.test').get('somePath')
nock.removeInterceptor(interceptor)

// Events
/// Global no match event
nock.emitter.on('no match', (req: any) => {})

// Nock Back
/// Setup
nock.back.fixtures = '/path/to/fixtures/'
nock.back.setMode('record')

/// Usage
const before = (def: nock.Definition) => {
  def.options = def.options || {}
  def.options.filteringScope = (scope: string) => {
    return /^https:\/\/api[0-9]*.example.test/.test(scope)
  }
github nock / nock / types / tests.ts View on Github external
enable_reqheaders_recording: true,
})

/// logging option
const nullAppender = (content: string) => {}
nock.recorder.rec({
  logging: nullAppender,
})

/// use_separator option
nock.recorder.rec({
  use_separator: false,
})

// .removeInterceptor()
nock.removeInterceptor({
  hostname: 'localhost',
  path: '/mockedResource',
})
nock.removeInterceptor({
  hostname: 'localhost',
  path: '/login',
  method: 'POST',
  proto: 'https',
})

const interceptor = nock('http://example.test').get('somePath')
nock.removeInterceptor(interceptor)

// Events
/// Global no match event
nock.emitter.on('no match', (req: any) => {})
github filestack / filestack-js / src / lib / api / upload / uploaders / s3.spec.ts View on Github external
it('should repsect retry config', async () => {
      // simulate first request network fail
      let networkFail = true;
      nock.removeInterceptor(interceptorS3);
      scope.persist(false);

      interceptorS3.twice().reply(
        function(url, _, cb) {
          if (networkFail) {
            networkFail = false;
            return cb('Error');
          }

          cb(null, mockPut(url, this.req.headers));
        },
        {
          etag: 'test',
        }
      );
github TheFive / osmbc / test / config / uc.config.js View on Github external
afterEach(async function() {
    nock.removeInterceptor(nockLoginPage);
    testutil.stopServer();
  });
  it("should open and not save wrong yaml", async function() {
github rapid7 / tokend / test / provider-generic.js View on Github external
afterEach(function() {
      nock.removeInterceptor(scope);
    });
github rapid7 / tokend / test / provider-transit.js View on Github external
afterEach(function() {
    nock.removeInterceptor(localVaultMock);
  });
github TheFive / osmbc / test / views.index.js View on Github external
afterEach(function(bddone){
      nock.removeInterceptor(nockLoginPage);
      return bddone();
    });
github rapid7 / tokend / test / provider-transit.js View on Github external
after(function() {
    nock.removeInterceptor(globalVaultMock);
    nock.cleanAll();
  });
github filestack / filestack-js / src / lib / api / upload / uploaders / s3.spec.ts View on Github external
it('should retry complete request on 202 status code', async () => {
      const mock202 = jest
        .fn()
        .mockName('202 mock')
        .mockReturnValue('');

      nock.removeInterceptor(interceptorComplete);
      scope.persist(false);
      scope.post('/multipart/complete').reply(202, () => mock202());
      scope.post('/multipart/complete').reply(200, (_, data) => mockComplete(JSON.parse(data)));

      const u = new S3Uploader({});
      u.setUrl(testHost);
      u.setApikey(testApikey);
      u.addFile(getTestFile());

      const res = await u.execute();

      expect(res[0].handle).toEqual('test_handle');
      expect(res[0].status).toEqual('test_status');

      expect(mock202).toHaveBeenCalledTimes(1);
      expect(mockComplete).toHaveBeenCalledTimes(1);
github JackuB / apish / src / mock.js View on Github external
        mock.interceptors.forEach((interceptor) => nock.removeInterceptor(interceptor));
      });