How to implement intervals/polling in angular2 to work with protractor?

扶醉桌前 提交于 2019-12-05 04:48:00

After some investigation, I found two possible solutions:

  1. browser.ignoreSynchronization = true instructs protractor to stop waiting for http calls and interval scripts. However, this will likely make writing e2e tests much harder, because now you have to manually wait for elements and pages to load before testing them.
  2. The protractor-xhr-only plugin basically does the same thing as ignoreSynchronization, but only for interval scripts. Protractor will still wait for $http calls to finish.

Neither of both are a perfect solution, but better than nothing.

https://github.com/angular/protractor/issues/3349#issuecomment-232253059

resolved this problem with help from juliemr:

this.ngZone.runOutsideAngular(() => {
  this.timer = Observable.interval(1000)
}

run timeout out of zone, then protractor will not wait for it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!