当nock发出https://github.com/torvalds/linux/commits?path=Documentation&since=2016-04-04T16:00:49Z时,它会响应一个参数,有时会有三个参数。我不确定它们是什么。每个参数的关键如下:
使用一个参数调用回调时:
qs,headers,path,protocol,method,hostname,port,socketTimeout,agent,clientName,transportName,maxRedirects,proto,host
使用三个参数调用回调时:
domain,_events,_maxListeners,output,outputEncodings,writable,_last,chunkedEncoding,shouldKeepAlive,useChunkedEncodingByDefault,sendDate,_headerSent,_header,_hasBody,_trailer,finished,_hangupClose,socket,connection,_headers,_headerNames,_removedHeader,path,write ,end,abort,on,once,metrics,timeoutCb,pipe
dnslookup,socketTimeout,retry,markdown-threshold,port,protocol,hostname,basepath,transport,method,instruments,headers,SVC_CHANNEL_STATUS,debug,path,checkServerIdentity,moduleRef,clientId,clientName,qs,agent,transportName,maxRedirects ,proto,host,getHeader
''(空字符串)
这是我用来生成密钥列表的代码:
nock.emitter.on('no match', function() {
for(var i=0;i<arguments.length;i++){
if(typeof arguments[i] === 'object')
console.log("\t",Object.keys(arguments[i]).join(", "));
else
console.log("\t'"+arguments[i]+"'");
}
});