私のテストでは、によって行われた HTTP リクエストを傍受しようとしていrequest/requestます。しかし、うまくいきません。ノックを使用するとhttp.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 :(
});
});
洞察はありますか?
編集:
結局のところ、これはプロキシ関連の問題です。