Comments (8)
The intereceptors are removed once they are "used".
Please check this: https://github.com/flatiron/nock#read-this
And please reopen if this is not the case.
from nock.
I setup the nock interceptor before each test so don't think it's that.
It's something to do with how restify modifies the node http request object, it's probably out of the scope of nock to try and fix it.
from nock.
Yeah, you're right, sorry my coffeescript reading is bad. Reopening this one just to make sure if it's not a nock bug.
You can add a .log(console.log)
to the scope like this to see what is going on under the hood:
https://github.com/flatiron/nock#logging
from nock.
No feedback, so I'm closing this one.
Please reopen once you have more info.
from nock.
I'm having the same problem. Nock is not working for the restify json client. I tried adding .log(console.log) but nothing was logged. It just hangs. You should be able to repro this quite easily.
from nock.
You can inspect what nock is trying to do by putting a callback using .log()
If that doesn't get you an insight, I'll need a failing test case (a gist is fine).
Pedro
On Tuesday, 19 de February de 2013 at 07:40, Jason Avinger wrote:
I'm having the same problem. Nock is not working for the restify json client. I tried adding .log(console.log) but nothing was logged. It just hangs. You should be able to repro this quite easily.
β
Reply to this email directly or view it on GitHub (#79 (comment)).
from nock.
Nock can't be used with Restify now.
Problem is when Nock is mocking http.request (or https) and returning what is defined in nock.response.
It is based on assumption that clientRequester is calling something like this :
var moduleCallback;
var req = http.request(options, function (res) {
moduleCallback();
});
req.end();
Nock knows when req.end is called.
But Restify (see http_client.js) is calling :
var moduleCallback;
var req = http.request(opts, function onResponse(res) {
req.emit('result', (err || null), res);
});
req.once('socket', function onSocket(socket) {
req.once('result', function () {
moduleCallback();
req.end();
})
});
So socket must be emitted before callback from http.request is called.
I don't know how this can be done. (I don't know how to access req object or attach new socket to it)
from nock.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue and add a reference to this one if itβs related. Thank you!
from nock.
Related Issues (20)
- [Node 18.12] Class extends value undefined is not a constructor or null HOT 2
- incompatible behaviour introduced with v13.3.2 HOT 17
- Interceptors not being removed in 13.3.2 HOT 2
- Replace npm debug with require('node:util').debuglog HOT 2
- Remove lodash HOT 1
- Application to become a nock maintainer. HOT 5
- Expand function fails on weird GET query params HOT 4
- reqheaders does not work when using an undefined requestBody HOT 3
- Add interceptor at the beginning of list
- Return 500 instead of 404 HOT 4
- Bun support for nock.disableNetConnect() HOT 1
- DNS resolve errors and not mocking a lot of requests HOT 7
- POST request with ReadStream request body does not return a response HOT 10
- Disabled discussions HOT 6
- Improve debug logging HOT 2
- Support Abort Signals HOT 1
- Add JSDoc HOT 8
- Using nock inside a stream pipeline with got causes it to hang forever since Node 20.10.0 HOT 2
- Debug logging broken in beta (14.0.0-beta.5) HOT 1
- Error when code cancels fetch response body stream (14.0.0-beta.6) HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nock.