Protractor does not wait to resolve promises on routes
See original GitHub issueHey,
I’m having a few issues getting protractor to wait for my dependencies to load in the route.
The basic code I have is this (which works fine in Angular itself)
$routeProvider.when('/login, {
templateUrl: 'template.html',
controller: 'LoginCtrl',
resolve: {
dependencies: function($q, $rootScope) {
var def = $q.defer();
yepnope([
{
load: [
'dependencies.js',
],
complete: function () {
$rootScope.$apply(function () {
def.resolve();
});
}
}
]);
return def.promise;
}
}
});
Protractor doesn’t wait for the route to resolve and doesn’t even display any content from the route. If the resolve dependency is removed the route successfully loads (but the test fails as the dependency isn’t loaded).
I’ve tried it with $timeout testing and that works fine, and as this isn’t a $http request, is there something I’m missing, or is this just not supported?
Thanks
Issue Analytics
- State:
- Created 9 years ago
- Comments:30 (6 by maintainers)
Top Results From Across the Web
Protractor does not wait for Angular to resolve - Stack Overflow
Since it's a timing issue, a workaround can be to wait for the element to be present before you assert that it's present:...
Read more >protractor-timeline-plugin - npm
* You can use waitForPromise() to have Protractor additionally wait for your * custom promise to be resolved inside of browser.waitForAngular().
Read more >CHANGELOG.md
It will affect TypeScript tests that are using async/await and a. miss some ... to install and fix reference to protractor - changed...
Read more >Top 18 Most Common AngularJS Developer Mistakes - Toptal
Common Mistake #5: Not Using Named Views With UI-ROUTER For Power”. The de facto routing solution for AngularJS has been, until now, the...
Read more >Using async/await - Protractor - end-to-end testing for AngularJS
Note: Never forget to add “await” keyword in an async function, it may bring some unexpected problem (e.g. your test might fail silently...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@juliemr , I think @sjelin meant angular/angular.js#14159.
@yxh10 That is not a long-term solution. Protractor should be aware of the views it’s rendering, as well as when the DOM is ready. Using
browser.wait
in that fashion may solve the immediate problem, but if it happens across many tests, the spec files would be littered with all of those statements. Not only that, but how would one choose an appropriatetimeToWaitInMilliseconds
? Having multiple blocks such as the one you have above would significantly slow down testing for larger applications.