我正在尝试使用sinon.spy来记录电话
beforeEach :
// Get restify JSON clinet instance
// Using rewire
// m_jsonClient is a private field
m_jsonClient = myMod.__get__('m_jsonClient')
jsonClientGetSpy = sandbox.spy(m_jsonClient, 'get')
它:
sut.FunctionThatCallsGetMethodOfJsonClient(,,,function (err, ..) {
jsonClientGetSpy.getCall(0).args[0] // url , i.e. /customers/123
jsonClientGetSpy.getCall(0).args[1] // Callback Function
// How can I access arguments?
// If myMod uses strict mode I got
// TypeError: 'caller', 'callee', and 'arguments' properties
// may not be accessed on strict mode functions or the arguments
// objects for calls to them
// Otherwise
// null
jsonClientGetSpy.getCall(0).args[1].arguments
})
如果间谍功能不同步,是否可以在回调中访问“返回值”?