Unit Testing Angular Service that uses $timeout with Jasmine’s Mock Clock

Do not make your test Async by using Jasmine’s clock. Instead, use $timeout.flush() to synchronously maintain the flow of the test. It may be a bit tricky to setup, but once you get it then your tests will be faster and more controlled.

Here’s an example of a test that does it using this approach:
https://github.com/angular/angular.js/blob/master/test/ngAnimate/animateSpec.js#L618

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)