Nock: No match for request

user269867 picture user269867 · Dec 1, 2017 · Viewed 9.9k times · Source

My nock call looks like as below

app_url='myshop.app.com'
result = nock(app_url, {
            reqheaders: {
                 "content-type": "application/json",
                 'authorization': 'Basic Auth'
            }
          })
        .get('/admin/products.json?collection_id=10001&limit=250&fields=id')    
        .reply(200, {
                "products": [
                { "id": 101},
                {"id": 102},
            ]
        });

Resolve :

(node:1378) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Nock: No match for request { .  

But now,

==========updated=============

I have updated my call which is not throwing an error but now it is not intercepting the request....It is still hitting shopify to fetch the data

Answer

Zveroslav  Kravets picture Zveroslav Kravets · Feb 28, 2019

Just add flag in scope { allowUnmocked: true }

nock('https://host.com', { allowUnmocked: true })
    .post(`/path`)
    .reply(200, {answer: "any"});