Testing all your Tasks - Julie Ralph
Why Stack Overflow recommends it
Stack Overflow users link it when explaining how Angular 2 zones trigger change detection and why Protractor keeps waiting on long-running async tasks.
Recommended by 1 people across 1 different months, 2016 to 2020.
What it is
A 21-minute ng-conf 2016 talk by Julie Ralph on how Angular 2 tasks, zones and the Testability class interact with end-to-end tests in Protractor. It covers how pending timeouts, intervals and promises affect when a test considers the app stable.
What people said
Recommends Tomer Almog · 2016-06 · Stack Overflow · on “Show Div Angular2”
Simplest way to invoke zones is to use a async behavior such as: setTimeout( () => { this.outletBox = true; }, 0); This will invoke a "digest" cycle. This video explains a lot about how it works: [this video]
Cites Tiago Roldão · 2016-10 · Stack Overflow · on “Protractor keeps waiting on finished HTTP requests”
(Short answer - any long-running tasks (timeouts, intervals, Promises or Observables) will block testing if not disposed correctly. Http cleans up after itself, so it is likely not your problem.) Http is most likely not your issue. Angular 2 uses zones to detect it's stable/unstable state, and Protractor uses a specific injectable class - the Testability Class [LINK] - to determine app state. Testability of all existing Angular2 apps in the page is exposed to the window object, which is how Protractor keeps tabs on Angular 2. Angular uses zones to maintain change detection. In userland, we get some control over where our code happens (in or out of angular) through NgZone, useful for two thin
Cites Daniel Grima · 2020-03 · Stack Overflow · on “Angular Protractor - Verifying page redirect”
In my case, apart from waiting for certain Promise objects, I also had something else causing the error. Long story short I have an interval that's responsible for showing the current time to the user. Since an interval is an asynchronous function, Protractor will assume that Angular is still running some function, and thus keeps on waiting for Angular to be "responsive". In Angular 2+, to cater for such a scenario, the setInterval() function needs to be run outside the Angular zone. Example ngOnInit() { this.now = new Date(); setInterval(() => { this.now = new Date(); }, 1000); } The above code will result in Protractor giving timeouts whenever the component with the interval exists on the