Sinon: spy.called to accept call count to verify call count

Created on 22 Jan 2014  ·  3Comments  ·  Source: sinonjs/sinon

It would be convenient to have a function for

spy.called(6).times // returns true if spy have been called 6 times

Than I can use sinon-chai

spy.should.have.been.called(6).times

Most helpful comment

Use spy.callCount to check the number of calls.

All 3 comments

And of course spy.called without function call should work as today

Use spy.callCount to check the number of calls.

@cjohansen There is a reason I use spy.calledTwice instead of spy.callCount === 2, because it is more readable. (Also it would play well with sinon-chai). Though I should maybe file the issue on sinon-chairepo instead.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brettz9 picture brettz9  ·  3Comments

OscarF picture OscarF  ·  4Comments

akdor1154 picture akdor1154  ·  4Comments

NathanHazout picture NathanHazout  ·  3Comments

ndhoule picture ndhoule  ·  4Comments