How to use the nock.activeMocks 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
/// .persist()
scope = nock('http://example.test')
  .persist()
  .get('/')
  .reply(200, 'Persisting all the way')

/// .pendingMocks()
strings = scope.pendingMocks()
strings = nock.pendingMocks()
if (!scope.isDone()) {
  console.error('pending mocks: %j', scope.pendingMocks())
}
console.error('pending mocks: %j', nock.pendingMocks())

/// .activeMocks()
nock.activeMocks() // $ExpectType string[]
nock('http://example.test').activeMocks() // $ExpectType string[]

// Logging
google = nock('http://example.test').log(console.log)

// Restoring
nock.restore()

// Enable/Disable real HTTP request
nock.disableNetConnect()
nock.enableNetConnect()

// using a string
nock.enableNetConnect('example.test')

// or a RegExp
github BitGo / BitGoJS / test / unit / wallet.ts View on Github external
after(function accelerateTxMockedAfter() {
      // make sure all nocks are cleared or consumed after the tests are complete
      nock.activeMocks().should.be.empty();
    });
github BitGo / BitGoJS / test / unit / wallet.ts View on Github external
before(function accelerateTxMockedBefore() {
      nock.activeMocks().should.be.empty();

      bitgo = new TestBitGo({ env: 'mock' });
      bitgo.initializeTestVars();
      bitgo.setValidate(false);
      wallet = new Wallet(bitgo, { id: walletId, private: { keychains: [userKeypair, backupKeypair, bitgoKey] } });
      wallet.bitgo = bitgo;
      bgUrl = common.Environments[bitgo.getEnv()].uri;
      smartBitUrl = common.Environments[bitgo.getEnv()].smartBitApiBaseUrl;

      // try to get the min change size from the server, otherwise default to 0.1 BTC
      // TODO: minChangeSize is not currently a constant defined on the client and should be added
      minChangeSize = bitgo.getConstants().minChangeSize || 1e7;
    });
github BitGo / BitGoJS / test / unit / wallet.ts View on Github external
// monkey patch the bitgo getConstants() function
        const oldGetConstants = bitgo.__proto__.getConstants;
        bitgo.__proto__.getConstants = () => ({
          // child fee rate in this test is 31378 sat/kb
          // so set the max fee rate just below that limit,
          // but above the combined fee rate of 20000
          maxFeeRate: 30000
        });

        yield wallet.accelerateTransaction({
          transactionID: parentTxId,
          feeRate,
          walletPassphrase: TestBitGo.TEST_WALLET1_PASSCODE
        });
        nock.activeMocks().should.be.empty();

        bitgo.__proto__.getConstants = oldGetConstants;
      }));
    });
github BitGo / BitGoJS / test / v2 / unit / keychains.ts View on Github external
after(function afterUpdatePassword() {
      nock.activeMocks().should.be.empty();
    });
  });
github BitGo / BitGoJS / test / unit / bitgo.js View on Github external
after(function() {
      nock.activeMocks().should.be.empty();
    });
  });
github BitGo / BitGoJS / test / unit / keychains.ts View on Github external
before(function beforeDescribe() {
      nock.activeMocks().should.be.empty();

      bitgo = new TestBitGo({ env: 'mock' });
      bitgo.initializeTestVars();
      bitgo.setValidate(false);
      keychains = bitgo.keychains();

      bgUrl = common.Environments[bitgo.getEnv()].uri;
    });
github BitGo / BitGoJS / test / unit / wallet.ts View on Github external
before(co(function *() {
      nock.activeMocks().should.be.empty();
      bgUrl = common.Environments[bitgo.getEnv()].uri;
    }));
github BitGo / BitGoJS / test / unit / bitgo.js View on Github external
after(function tokenDefinitionsAfter() {
      nock.activeMocks().should.be.empty();
    });
  });
github BitGo / BitGoJS / test / v2 / unit / coins / xrp.js View on Github external
after(function() {
    nock.activeMocks().should.be.empty();
  });