Giter VIP home page Giter VIP logo

Comments (8)

pgte avatar pgte commented on June 23, 2024

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.

cjroebuck avatar cjroebuck commented on June 23, 2024

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.

pgte avatar pgte commented on June 23, 2024

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.

pgte avatar pgte commented on June 23, 2024

No feedback, so I'm closing this one.
Please reopen once you have more info.

from nock.

jasonav avatar jasonav commented on June 23, 2024

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.

pgte avatar pgte commented on June 23, 2024

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.

lblazecki avatar lblazecki commented on June 23, 2024

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.

lock avatar lock commented on June 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.