How to use the nock.isActive 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 plotly / falcon / test / backend / datastores.elasticsearch-v2.spec.js View on Github external
before(function() {
        url = `${elasticsearchConnections.host}:${elasticsearchConnections.port}`;

        // Enable nock if it has been disabled by other specs
        if (!nock.isActive()) nock.activate();

        // Uncomment to test dockerized server:
        //
        // elasticsearchConnections.host = 'http://localhost';
        // elasticsearchConnections.port = '9200';
        // nock.restore();
    });
github wikimedia / restbase / test / features / security / security.js View on Github external
before(() => {
        if (!nock.isActive()) {
            nock.activate();
        }
        return server.start()
        .then(() => {
            // Do preparation requests to force siteInfo fetch so that we don't need to mock it
            return P.join(
                preq.get({uri: `${server.config.bucketURL()}/title/Main_Page`}),
                preq.get({uri: `${server.config.bucketURL('ru.wikipedia.beta.wmflabs.org')}/title/${encodeURIComponent('Заглавная_страница')}`})
            );
        });
    });
    after(() => server.stop());
github plotly / falcon / test / backend / datastores.athena.spec.js View on Github external
before(function() {
        // Enable nock if it has been disabled by other specs
        if (!nock.isActive()) nock.activate();
    });
github poetic / nock-vcr-recorder / lib / use-cassette.js View on Github external
function beforeTest(cassettePath, options) {
  nockReset();

  // I feel like this could be written better. Some duplication here
  if (options.mode === 'all') {
    nockStartRecording();
  } else if (fs.existsSync(cassettePath)) {
    if (!nock.isActive()) {
      nock.activate();
    }

    nock.load(cassettePath);
  } else {
    nockStartRecording();
  }
}
github mattermost / mattermost-redux / test / test_helper.js View on Github external
activateMocking() {
        if (!nock.isActive()) {
            nock.activate();
        }
    }
github balena-io / balena-cli / tests / helpers.ts View on Github external
export const balenaAPIMock = () => {
	if (!nock.isActive()) {
		nock.activate();
	}

	return nock(/./)
		.get('/config/vars')
		.reply(200, {
			reservedNames: [],
			reservedNamespaces: [],
			invalidRegex: '/^d|W/',
			whiteListedNames: [],
			whiteListedNamespaces: [],
			blackListedNames: [],
			configVarSchema: [],
		});
};
github balena-io / balena-cli / tests / balena-api-mock.ts View on Github external
constructor() {
		nock.cleanAll();

		if (!nock.isActive()) {
			nock.activate();
		}

		this.scope = nock(BalenaAPIMock.basePathPattern);

		nock.emitter.on('no match', this.handleUnexpectedRequest);
	}
github swagger-api / swagger-js / test / resolver / index.js View on Github external
beforeAll(() => {
            Swagger.clearCache()

            if (!nock.isActive()) {
              nock.activate()
            }

            nock.cleanAll()
            nock.disableNetConnect()

            const nockScope = nock('http://mock.swagger.test')

            if (currentCase.remoteDocuments) {
              Object.keys(currentCase.remoteDocuments).forEach((key) => {
                const docContent = currentCase.remoteDocuments[key]
                nockScope
                  .get(`/${key}`)
                  .reply(200, docContent, {
                    'Content-Type': 'application/yaml'
                  })
github ambrosus / ambrosus-nop / test / services / setup_creator.js View on Github external
beforeEach(() => {
      if (!nock.isActive()) {
        nock.activate();
      }
    });
github syl20lego / rn-skeleton / test / unit / api / users.api.spec.js View on Github external
beforeEach(() => {
        if (!nock.isActive()) nock.activate();
        nock.disableNetConnect();
    });