简体   繁体   English

在量角器测试中跳过$ timeout

[英]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. 我在应用程序中添加了一个最小的ajax等待时间,但是我希望我的e2e测试尽快完成。 Can protractor be forced to skip waiting for $timeout to finish its wait time? 量角器是否可以被迫跳过等待$timeout来完成其等待时间?

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

During e2eTests, I would like waitTimeRemaning to be skipped and move straight to the resolve. 在e2eTests期间,我希望跳过waitTimeRemaning并直接进行解决。

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. 同步刷新将在下一个waitTimeRemaining毫秒中发生的延迟函数的队列。

This only works when you are using the angular mock $timeout . 这仅在使用角度模拟$timeout

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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