Twitter Call us on +44 (0)1256 486557

Checking haveBeenCalledWith more than once in the same method call with Jasmine

Sometimes in Jasmine you want to spy on a method and check it’s been called multiple times.  This is especially relevant with Sencha Touch for global methods like Ext.create.

There are a couple of things you can do.  Firstly you can look at the call count for the spied method, but most of the time that’s not good enough as you need to differentiate between the calls.

So the easiest way to do it is to look at the ‘argsForCall’ attribute on the spied method.  This is an array and will have an entry for each call.  Below is an example: