0

We have an Angular app that uses a very long running HTTP request waiting for events from the server. When testing with Protractor, all related articles (e.g. here: https://valor-software.com/articles/testing-with-protractor-how-to-fix-synchronization-issues.html and here: https://jarifibrahim.github.io/blog/protractor-and-page-synchronization/) suggest running the checks outside the Angular zone, because otherwise Protractor waits for the long HTTP request to finish and eventually times out. However, it is not clear to me, as I haven't found a complete e2e test related to that, how to inject NgZone in a typical Angular Protractor test, consisting of a Page Object and a test (.spec.ts) file, as described here: https://coryrylan.com/blog/introduction-to-e2e-testing-with-the-angular-cli-and-protractor. I tried importing NgZone in the Page Object class constructor as such constructor(private ngZone: NgZone) in a typical Angular component fashion, but this doesn't work. What am I missing?

AsGoodAsItGets
  • 2,886
  • 34
  • 49
  • Check out this https://stackoverflow.com/a/66111219/9150146 maybe it'll help somehow. In #2 you may want to write a function to wait until either one is true – Sergey Pleshakov Apr 07 '21 at 17:40
  • I read that answer too, but I don't see how it's related to my question. Are you implying that I should get NgZone within my Protractor test from `getAllAngularTestabilities()[0]._ngZone`? – AsGoodAsItGets Apr 07 '21 at 21:33

0 Answers0