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.
Logic:
$('#mydiv').fadeOut('normal', function () {
// this is called AFTER the test ends
// but should be called after jasmine.Clock.tick(1000);
$(this).remove();
})
Spec:
it('should pass', function () {
jasmine.Clock.useMock();
// call logic
jasmine.Clock.tick(1000);
// using jasmine-jquery matcher
expect($('#mydiv')).not.toExist();
})
Test fails with the message:
Expected '<div id="mydiv" style="opacity: 0; "></div>' not to exist.
It means that effect ended correctly, but complete function was not called. It actually gets called after test runner finishes execution.
I am not sure whether it is bug to be reported to JQuery or to Jasmine developers. Maybe someone would suggest workaround.
My goal is to test that element was removed after the logic execution, so I need not.toExist() matcher.
Please see the answer at your github issue. jQuery effects and Jasmine's mock clock are not compatible.