简体   繁体   中英

Skip $timeout during Protractor tests

I've added a minimum wait time for ajax in my application, but I would like my e2e tests to complete as quickly as possible. Can protractor be forced to skip waiting for $timeout to finish its wait time?

$timeout(function() {
    deferment.resolve(response);
}, waitTimeRemaining);

During e2eTests, I would like waitTimeRemaning to be skipped and move straight to the resolve.

Not sure if this works in protractor (never used it), but you should be able to do

$timeout.flush(waitTimeRemaining)

to synchronously flush the queue of deferred functions that would happen in the next waitTimeRemaining milliseconds.

This only works when you are using the angular mock $timeout .

https://docs.angularjs.org/api/ngMock/service/$timeout

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM