Unable to remove interceptors using nock
03:34 17 Jul 2019

I am using nock and I'm trying to remove interceptors for certain hostname.

I have tried using:

nock.removeInterceptor({
      hostname: 'somehostname.com',
      proto: 'https',
      path: '/',
    }),

When I print the result of this, it actually gives me true

I have also tried:

const mock = nock(somehostname.com)
    .persist()
    .post('/endpoint')
    .reply(200);

nock.removeInterceptor(mock)

But this gives me false somehow.

The way I'm checking if this is working is by printing the activeMocks: nock.activeMocks() And it still has the interceptors that I'm trying to remove.

Does anyone know what happens?

node.js nock