Clone and edit this document
Runkit
Runkit
home page
user forum
new notebook
clone notebook
download notebook
support & documentation
log in
sign up
new notebook
help & feedback
clone this notebook
download this notebook
Sign In
Sign Up
node-nock/nock#768
node v8.17.0
version:
1.0.0
endpoint
share
tweet
Reproduceable testcase for https://github.com/node-nock/nock/issues/768
const http = require('http') const nock = require('nock@9.0.27') const data = {foo: 'bar'} nock('http://example.com') .post("/baz", {foo: 'bar'}) .replyWithError('invalid request') const request = http.request({ hostname: 'example.com', port: 80, path: '/baz', method: 'POST', headers: { 'Content-Type': 'application/json', 'Content-Length': JSON.stringify(data).length } }) request.on('error', console.log) request.write(JSON.stringify(data)) request.end() // logs Error: invalid request
Loading…
no comments
sign in
to comment