Skip to content

nock does not intercept requests when recorder is on #247

@redben

Description

@redben

May be I am missing something but when enabling recorder, no requests are intercepted by nock.
mocha test :

describe("nock recorder issue", function () {

    var nock = require('nock'), // v0.50.0
        request = require('request'); // v2.36.0

    nock.disableNetConnect();

    it('works without recorder', function (done) {

        expected = nock('http://localhost').get('/').reply(200);

        request.get('http://localhost/', function () {
            expected.done();
            done();
        });

    })


    it('should work with recorder (but fails)', function (done) {

        nock.recorder.rec();
        expected = nock('http://localhost').get('/').reply(200);

        request.get('http://localhost/', function (error) {
            // when recorder is on, requests are not intercepted
            // and *real requests are emitted*
            // even though nock.disableNetConnect() is used
            // this one throws ECONNREFUSED because no server is
            // running on localhost
            console.log(error);
            expected.done();
            done();
        });
    })

});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions