Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// 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)
}
}
})
/// .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
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
function verify() {
/* jshint expr:true */
if (!nock.isDone()) {
logger.error('pending mocks: %j', nock.pendingMocks());
}
expect(nock.isDone()).to.be.true;
}
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;
}
function assertNock(done) {
try {
assert.ok(nock.isDone());
done();
} catch (err) {
console.error('pending mocks: %j', nock.pendingMocks());
done(err);
}
}
afterEach(() => expect(nock.pendingMocks()).toEqual([]));