Last active
October 21, 2021 07:23
-
-
Save andreroggeri/c4287ea3c67e7623364b60f2b3506945 to your computer and use it in GitHub Desktop.
Checks the Angular stability and logs on the console. Useful for debugging long protractor waits
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copy and paste the code below on your browser console | |
* It will log the stable changes and how long it took to become stable | |
*/ | |
let currentStatus = undefined; | |
let root = $('app-root'); // Change this selector to the component that you'll be watching (Usually the root component) | |
let startTime = new Date(); | |
let stabilityChecker = setInterval(() => { | |
let newStatus = window.getAngularTestability(root).isStable(); | |
if (currentStatus !== newStatus) { | |
currentStatus = newStatus; | |
console.log(`[StabilityChecker] Stable status changed to => ${currentStatus}`); | |
if (currentStatus) { | |
let delta = (new Date() - startTime) / 1000; | |
console.log(`[StabilityChecker] Took ${delta} seconds`); | |
} else { | |
startTime = new Date(); | |
} | |
} | |
}, 0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment