错误:Nock:没有匹配的请求 [英] Error: Nock: No match for request

查看:161
本文介绍了错误:Nock:没有匹配的请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到以下错误

{ 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?

推荐答案

使用.log(console.log)查看确切的错误消息.

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**.

如果说的是真的,那么您的要求应该很好.但是,如果显示为false,则检查两个请求并确保它们匹配.

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

这篇关于错误:Nock:没有匹配的请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆