Twitter Call us on +44 (0)1256 486557

Modifying Jasmine spies after creation with Sencha Touch

Sometimes you might want to spy on a method which doesn’t call through but then later in the same suite of tests does call through.  For example I might spy on Ext.create because I want to check it was called but I don’t want it to dynamically try and include the class I am trying to instantiate in my test (for example it may not be a real class).

But later on in the same test I want to check the resulting instance that’s created as a result of my function call.  Well we can simply adjust the spy to do this for us: