How to use the nock.restore 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 balena-io / balena-cli / tests / balena-api-mock.ts View on Github external
public done() {
		// scope.done() will throw an error if there are expected api calls that have not happened.
		// So ensures that all expected calls have been made.
		this.scope.done();
		// Remove 'no match' handler, for tests using nock without this module
		nock.emitter.removeListener('no match', this.handleUnexpectedRequest);
		// Restore unmocked behaviour
		nock.cleanAll();
		nock.restore();
	}
github adobe / helix-cli / test / testRemotePublishCmd.botconfig.js View on Github external
beforeEach('Setting up Fake Server', function bef() {
    deleted = clearHelixEnv();
    this.timeout(5000);
    writeDictItem = sinon.fake.resolves(true);
    purgeAll = sinon.fake.resolves(true);

    RemotePublishCommand = proxyquire('../src/remotepublish.cmd', {
      '@adobe/fastly-native-promises': () => ({
        transact: (fn) => fn(3),
        writeDictItem,
        purgeAll,
      }),
    });

    // ensure to reset nock to avoid conflicts with PollyJS
    nock.restore();
    nock.cleanAll();
    nock.activate();

    scope = nock('https://adobeioruntime.net')
      .post('/api/v1/web/helix/helix-services/publish@v2')
      .reply(200, {})
      .post('/api/v1/web/helix/helix-services/logging@v1')
      .reply(200, {});
  });
github ericclemmons / node-recorder / src / Recorder.ts View on Github external
setupNock() {
    nock.restore();
    nock.cleanAll();

    const interceptor = nock(/.*/).persist();
    const recorder = this;

    Object.keys(Methods).forEach((m) => {
      interceptor
        .intercept(/.*/, m)
        .reply(async function reply(uri, body, respond) {
          // @ts-ignore
          const { method, req } = this as any;
          const { headers } = req;
          const [options] = REQUEST_ARGUMENTS.get(req);

          const interceptedRequest: InterceptedRequest = {
            body,
github ziyasal / consulr / test / consulr.spec.js View on Github external
test.after.always('cleanup', t => {
  nock.cleanAll();
  nock.restore();
});
github ambrosus / ambrosus-nop / test / services / setup_creator.js View on Github external
afterEach(async () => {
      nock.cleanAll();
      nock.restore();
      await removeFile(destChainJsonPath);
    });
github github-tools / github / test / search.spec.js View on Github external
after(function() {
      nock.cleanAll();
      nock.restore();
   });
});
github poetic / nock-vcr-recorder / lib / use-cassette.js View on Github external
function nockReset() {
  nock.cleanAll();
  nock.recorder.clear();
  nock.restore();
}
github poetic-labs / nock-vcr-recorder-mocha / lib / recorder.js View on Github external
function startRecording(options) {
  nock.restore();
  nock.recorder.clear();
  nock.recorder.rec(options.recorder);
}