How to use the nock.pendingMocks 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 philschatz / project-bot / test / index.spec.js View on Github external
// mutation moveCard
      nock('https://api.github.com')
        .post('/graphql')
        .reply(200, (uri, requestBody) => {
          requestBody = JSON.parse(requestBody)
          expect(requestBody.query).toContain('mutation moveCard')
          expect(requestBody.variables.cardId).toBeTruthy()
          expect(requestBody.variables.columnId).toBeTruthy()
        })
    }

    // Receive a webhook event
    await probot.receive({ name: eventName, payload })

    if (!nock.isDone()) {
      console.error(nock.pendingMocks())
      expect(nock.isDone()).toEqual(true)
    }
  }
})
github nock / nock / types / tests.ts View on Github external
/// .cleanAll()
nock.cleanAll()

/// .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
github nock / nock / types / tests.ts View on Github external
scope.isDone() // will return false

nock.isDone()

/// .cleanAll()
nock.cleanAll()

/// .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
github cloudfoundry-incubator / service-fabrik-broker / test / test_broker / eventmesh.ApiServerClient.spec.js View on Github external
function verify() {
  /* jshint expr:true */
  if (!nock.isDone()) {
    logger.error('pending mocks: %j', nock.pendingMocks());
  }
  expect(nock.isDone()).to.be.true;
}
github cloudfoundry-incubator / service-fabrik-broker / test / test_broker / mocks / index.js View on Github external
function verify() {
  /* jshint expr:true */
  logger.info('checking mocks: %j', nock.pendingMocks());
  if (!nock.isDone()) {
    logger.error('pending mocks: %j', nock.pendingMocks());
  }
  expect(nock.isDone()).to.be.true;
}
github cloudant / couchbackup / test / fatalerrors.js View on Github external
function assertNock(done) {
  try {
    assert.ok(nock.isDone());
    done();
  } catch (err) {
    console.error('pending mocks: %j', nock.pendingMocks());
    done(err);
  }
}
github integrations / slack / test / integration / index.js View on Github external
afterEach(() => expect(nock.pendingMocks()).toEqual([]));