Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict'
// Tests for `.replyWithFile()`.
const path = require('path')
const { expect } = require('chai')
const proxyquire = require('proxyquire').preserveCache()
const nock = require('..')
const got = require('./got_client')
require('./setup')
const textFile = path.join(__dirname, '..', 'assets', 'reply_file_1.txt')
const binaryFile = path.join(__dirname, '..', 'assets', 'reply_file_2.txt.gz')
describe('`.replyWithFile()', () => {
it('reply with file', async () => {
const scope = nock('http://example.test')
.get('/')
.replyWithFile(200, textFile)
const { statusCode, body } = await got('http://example.test/')
'use strict'
const path = require('path')
const { expect } = require('chai')
const sinon = require('sinon')
const proxyquire = require('proxyquire').preserveCache()
const Interceptor = require('../lib/interceptor')
const nock = require('..')
const got = require('./got_client')
require('./setup')
it('scope exposes interceptors', () => {
const scopes = nock.load(path.join(__dirname, 'fixtures', 'goodRequest.json'))
expect(scopes).to.be.an.instanceOf(Array)
expect(scopes).to.have.lengthOf.at.least(1)
scopes.forEach(scope => {
scope.interceptors.forEach(interceptor => {
expect(interceptor).to.be.an.instanceOf(Interceptor)
interceptor.delayConnection(100)
'use strict'
const http = require('http')
const fs = require('fs')
const path = require('path')
const { beforeEach, test } = require('tap')
const proxyquire = require('proxyquire').preserveCache()
const nock = require('..')
require('./cleanup_after_each')()
beforeEach(done => {
nockBack.setMode('wild')
nockBack.fixtures = `${__dirname}/fixtures`
done()
})
const nockBack = nock.back
const exists = fs.existsSync
function testNock(t) {
let dataCalled = false