Testing e2e and $ timeout

In my application, I have a $ timeout that fires every minute and assigns a different $ timeout. Because of this, my e2e tests are waiting for $ timeout and do not want to work at all. As far as I understand, there is no way to say karma, so as not to wait for a certain $ timeout. But is there a way to detect that the code works in a karma environment and does not run this $ timeout at all?

+4
source share
2 answers

I did not find an elegant solution. At this point, I decided to pass the flag to the URL, parse it, and disable this special $ timeout, depending on this flag. This solution does not look very good, but it works. Hopefully later angular will have some kind of e2e dsl commands for this kind of thing.

0
source

From AngularJS docs :

In tests, you can use $ timeout.flush () to synchronously flush the pending function queue.

If you call a lot of $ timeouts, you can use the waitsFor jasmine function. Something like that:

waitsFor(function () { $timeout.flush(); return workedThreeTimes(); }, 'should run something per minute', 1000 * 60 * 3); 

(sorry for my English)

-2
source

Source: https://habr.com/ru/post/1486989/


All Articles