有一个功能会很方便
spy.called(6).times // returns true if spy have been called 6 times
比我可以使用sinon-chai
spy.should.have.been.called(6).times
当然spy.called
没有函数调用应该像今天一样工作
使用spy.callCount
来查看调用次数。
@cjohansen我使用spy.calledTwice
而不是spy.callCount === 2
是有原因的,因为它更具可读性。 (它也可以和 sinon-chai 一起玩)。 虽然我可能应该在sinon-chai
repo 上提交问题。
最有用的评论
使用
spy.callCount
来查看调用次数。