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

kbirger picture kbirger  路  3Comments

OscarF picture OscarF  路  4Comments

stevenmusumeche picture stevenmusumeche  路  3Comments

fearphage picture fearphage  路  3Comments

ljian3377 picture ljian3377  路  3Comments