Created
June 7, 2017 00:31
-
-
Save emanlove/57c9580b3964565e9ff9db260cb3517a to your computer and use it in GitHub Desktop.
Test code that is run in browser devtools/console window proving out javascipt code for mimicing Protractor's waitForAngular function.
This file contains hidden or 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
var callback = function () {console.log('*')}; | |
var el = document.querySelector('[ng-app]'); | |
var h = setInterval(function w4ng() { | |
console.log('.'); | |
try { | |
if (window.angular && !(window.angular.version && | |
window.angular.version.major > 1)) { | |
/* ng1 */ | |
angular.element(el).injector().get('$browser'). | |
notifyWhenNoOutstandingRequests(callback); | |
} else if (window.getAngularTestability) { | |
window.getAngularTestability(el).whenStable(callback); | |
} else if (window.getAllAngularTestabilities) { | |
var testabilities = window.getAllAngularTestabilities(); | |
var count = testabilities.length; | |
var decrement = function() { | |
count--; | |
if (count === 0) { | |
callback(); | |
} | |
}; | |
testabilities.forEach(function(testability) { | |
testability.whenStable(decrement); | |
}); | |
} | |
} catch (err) { | |
console.log(err.message); | |
callback(err.message); | |
} | |
}, 10); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment