Skip to content

Instantly share code, notes, and snippets.

@isaacs
Created February 11, 2020 20:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isaacs/4a3abdc4e794190cc370fa501762dd94 to your computer and use it in GitHub Desktop.
Save isaacs/4a3abdc4e794190cc370fa501762dd94 to your computer and use it in GitHub Desktop.
const nock = require('nock')
const server = nock('http://localhost:8080')
const CONTENT = 'this is fine'
server
.get('/test')
.times(1)
.reply(200, CONTENT)
const fetch = require('./')
require('http').createServer((q, s) => s.end('from the other server'))
.listen(8080)
fetch('http://localhost:8080/test')
.then(() => fetch('http://localhost:8080/test'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment