Skip to content

allowUnmocked + query string = interception fail #1421

@NatalieWolfe

Description

@NatalieWolfe

What is the expected behavior?

When allowUnmocked is set to true there should be no change in how nock matches requests.

What is the actual behavior?

When allowUnmocked is set to true, query strings must be specified using the .query function, not in the path string.

Possible solution

This is sort of the opposite problem as #490, which was fixed in #955. That fix may have introduced this problem.

How to reproduce the issue

'use strict'

const nock = require('nock')
const http = require('http')

nock('http://localhost', {allowUnmocked: true})
  .get('/foo?bar=baz')
  .reply(418, 'Teapots')

const req = http.get('/foo?bar=baz', (res) => {
  console.log(res.statusCode)
})

req.on('error', console.error)

Does the bug have a test case?

Versions

Software Version(s)
Nock 9.1.9, 10.0.6
Node 8.12.0, 10.15.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions