0

I'm trying to write end-to-end tests. I'm using cytoscape.js and angular 11. Cytoscape.js constantly renders a canvas to make graph visualization. So change detection is always triggered. To eliminate that I'm using the runOutsideAngular method of ngZone like below

this.ngZone.runOutsideAngular(() => {
  this._g.cy = cytoscape({
    container: containerElem,
    zoom: 1,
  });
});

So with this way change detection is not fired constantly.

I'm also checking the detected changes in my main angular component with the below code.

ngAfterViewChecked(): void {
  console.log('change detected!');
}

My problem is with end-to-end testing. In tests even if there aren't any changes (I'm opening the developer console and checking) and the website looks idle, I see that the test still waits for something. It WAITS LIKE 5-6 seconds. This makes all my tests take too much time.

I'm suspecting from waitForAngular. But since there are not changes, it shouldn't be the reason.

Any ideas? Thank you

canbax
  • 3,432
  • 1
  • 27
  • 44
  • Have you tried to turn off waitForAngular? I believe the new magic is `browser.waitForAngularEnabled(false);` – cnishina Jan 19 '21 at 09:41
  • There is no magic. Setting it to false is simply removes all the usefulness of angular in testing. If I set it to false, I should set hardcoded sleep values for my async operations. I don't want that. I don't want to set a hardcoded value to make the browser wait. – canbax Jan 19 '21 at 09:43
  • this may help you https://stackoverflow.com/questions/55240582/failed-script-timeout-result-was-not-received-in-11-seconds-from-task-protra/55246647#55246647 and this https://stackoverflow.com/a/57664113/9150146 – Sergey Pleshakov Jan 19 '21 at 15:16
  • @SergeyPleshakov thank you. I'm already using `runOutsideAngular`. For the second, I don't want to set hard-coded sleep values. They don't work if the environment changes. (execute the same in a laptop might take longer) – canbax Jan 19 '21 at 15:28
  • hm... the second url doesn't recommend the use of hardcoded sleeps – Sergey Pleshakov Jan 19 '21 at 21:42
  • hm, I think you are right. `await browser.wait` will wait for a condition. Maybe I can use conditions and disable `waitForAngular`. I will try. Thank you – canbax Jan 20 '21 at 05:43

0 Answers0