Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Nock: No match for request

Tags:

I am receiving following error

{ error:     { Error: Nock: No match for request {      "method": "GET",      "url": "http://localhost:3000/admin/orders/30075889/transactions.json",      "headers": {        "content-type": "application/json",        "host": "localhost:3000"      }    } Got instead {      "method": "GET",      "url": "http://localhost:3000/admin/orders/30075889/transactions.json",      "headers": {        "content-type": "application/json",        "host": "localhost:3000"      }    } 

The url is as expected, not sure what's wrong, any pointer?

like image 316
user269867 Avatar asked Feb 07 '18 22:02

user269867


1 Answers

Use .log(console.log) to see the exact error message.

EX :

nock('https://test.org/sample') .persist() .log(console.log) .get('/test') .query({}) .reply(200, response); 

When you use this and run the test, you will see something like this in the console

matching https://test.org/sample/test to GET https://test.org/sample/test with query({}): **true/false**. 

If it says true, your request should be good. But if it says false, check both the requests and make sure they match.

like image 56
user2092512 Avatar answered Sep 18 '22 11:09

user2092512