Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Jasmine Clock mocking and JQuery effect 'complete' function does not go along well #184

vkovalskiy opened this Issue · 4 comments

4 participants


I have found a problem testing JQuery animations. The problem is that during jasmine.Clock.useMock() mode JQuery does not call complete function after effect execution.

I am not sure whether it is jasmine ot jquery problem. The complete ticket is here:


This is a known issue. jQuery animations depend on setTimeout and the jasmine mock clock stubs that function. You need to turn off jQuery animations ($ in a global beforeEach.

I think this is a good pattern - you don't want animations messing with your tests. If you need to test with animations on I suggest you add incremental browser-based testing to your stack.

@infews infews closed this

I have tried to turn off animations in a beforeEach of a particular describe block but no result (complete remains uncalled).

What did you mean exactly saing global beforeEach? Where the statement should be placed to resolve jQuery problem?


You need to turn off jQuery animations ($ in a global beforeEach.

Ah, this worked for me! It was not clear to me initially why an effect/animation such as fadeOut() would not act as expected in conjunction with


doing the below to turn off animations in my specific describe() function worked:

      jasmine.Clock.useMock(); = true;

Just an FYI for those finding this issue, jQuery 2.0 does not have an method. You need use this instead:

$ = true;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.