var nock=require('nock'),
request=require('request');
nock('https://www.google.com',
{ allowUnmocked: true })
.log(console.log)
.get("/abc")
.query({'user':'fred'})
.reply(200, "Match!")
request('https://www.google.com/abc?user=fred', function (error, response, body) {
if (!error && response.statusCode == 200) {
console.log(body);
} else{
console.log(error ? "error: " + error : "response.statusCode: "+ response.statusCode);
}
});
With the code above, my request does NOT match and goes to google.com.
$ node nockTest.js
response.statusCode: 404
By changing allowUnmocked to false, I get:
$ node nockTest.js
matching https://www.google.com:443?user=fred to GET https://www.google.com:443/abc with query({"user":"fred"}): true
Match!
I am able to work around this and keep allowUnmocked=true by using a filteringPath to remove the query. Is this a bug or am I missing something here? Thanks!
With the code above, my request does NOT match and goes to google.com.
$ node nockTest.js
response.statusCode: 404
By changing allowUnmocked to false, I get:
$ node nockTest.js
matching https://www.google.com:443?user=fred to GET https://www.google.com:443/abc with query({"user":"fred"}): true
Match!
I am able to work around this and keep allowUnmocked=true by using a filteringPath to remove the query. Is this a bug or am I missing something here? Thanks!