0
我试图窥视传递到副作用-EY功能,它是由具有一个匿名函数容器接收一个最终PARAM间谍所有ARGS传递到功能组合物
(实际上是所有PARAMS我想存根,但从事间谍活动是一个开始)
classA.js
const classB = require(`classB.js`)
const doWork = (a, b, c, d, e) => {
//do things with a, b, c, d, e to make x, y, z…
return classB.thingToSpyOn(a, b, c, x, y)(z) //<=note curry here
}
ClassA.spec.js
const classA = require(`classA.js`)
const classB = require(`classB.js`)
describe(`doWork`,() => {
sinon.spy(classB, 'thingToSpyOn')
classA.doWork(“foo”, “bar”, “baz”, “bing”, “boing”)
//now i can get the spy to tell me what it received as a, b, c, x, y
console.log(classB.thingToSpyOn.args)
...
但如何记录收到的内容为z
?
这正是我所需要的。非常感谢! – tonywoode