0
在我的测试中,我试图拦截由request/request
发出的HTTP请求。但它不起作用。当我使用http.request()
诺克完美。
这里是个例:NodeJS - Nock不拦截使用`request/request`模块发出的请求
it('A test case', function() {
nock('http://www.google.com')
.get('/')
.reply(200, { response: 'Hello from Nock!' });
request('http://www.google.com/', function(err, res, body) {
console.log(body); // It displays the actual response :(
});
});
任何见解?!
编辑:
毕竟,它代理的相关问题。
您是如何为通过代理发出的请求设置测试的? – Kwhitejr