嗨,我正在尝试箭库 https://github.com/flatiron/nock/blob/master/README.md但正在努力匹配查询字符串上的随机模式。我认为类似下面的代码应该可以工作,但我无法让任何东西工作。
var nock, request;
request = require('request');
nock = require('nock');
nock("http://www.google.com").filteringPath(/.*/g).get("/").reply(200, "this should work?");
request("http://www.google.com?value=bob", function(err, res, body) {
return console.log(body);
});
我以前没用过这个,但是通过阅读docs https://github.com/flatiron/nock#path-filtering也许这会有所帮助。
像这样的事情怎么样:
var nock = require('nock');
var request = require ('request');
nock("http://www.google.com")
.filteringPath(function(path){
return '/';
})
.get("/")
.reply(200, "this should work?");
request("http://www.google.com?value=bob", function(err, res, body) {
return console.log(body);
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)