protractor: Protractor does not wait to resolve promises on routes
Hey,
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
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 30 (6 by maintainers)
Commits related to this issue
- fix(ngRoute): make route.resolve count as a pending request Protractor users were having a problem where if they had asynchonous code in a route.resolve variable, Protractor was not waiting for that ... — committed to sjelin/angular.js by sjelin 8 years ago
- fix(ngRoute): make route.resolve count as a pending request Protractor users were having a problem where if they had asynchonous code in a route.resolve variable, Protractor was not waiting for that ... — committed to sjelin/angular.js by sjelin 8 years ago
- fix(ngRoute): make route.resolve count as a pending request Protractor users were having a problem where if they had asynchonous code in a route.resolve variable, Protractor was not waiting for that ... — committed to sjelin/angular.js by sjelin 8 years ago
- fix(ngRoute): make `route.resolve` count as a pending request Protractor users were having a problem where if they had asynchonous code in a route.resolve variable, Protractor was not waiting for tha... — committed to sjelin/angular.js by sjelin 8 years ago
- fix(ngRoute): make `route.resolve` count as a pending request Protractor users were having a problem where if they had asynchonous code in a route.resolve variable, Protractor was not waiting for tha... — committed to sjelin/angular.js by sjelin 8 years ago
- fix(ngRoute): make `route.resolve` count as a pending request Protractor users were having a problem where if they had asynchonous code in a route.resolve variable, Protractor was not waiting for tha... — committed to sjelin/angular.js by sjelin 8 years ago
- fix(ngRoute): make `route.resolve` count as a pending request Protractor users were having a problem where if they had asynchonous code in a route.resolve variable, Protractor was not waiting for tha... — committed to sjelin/angular.js by sjelin 8 years ago
- fix(ngRoute): make `route.resolve` count as a pending request Protractor users were having a problem where if they had asynchonous code in a route.resolve variable, Protractor was not waiting for tha... — committed to sjelin/angular.js by sjelin 8 years ago
- fix(ngRoute): make `route.resolve` count as a pending request Protractor users were having a problem where if they had asynchonous code in a route.resolve variable, Protractor was not waiting for tha... — committed to sjelin/angular.js by sjelin 8 years ago
- fix(ngRoute): make `route.resolve` count as a pending request Protractor users were having a problem where if they had asynchonous code in a route.resolve variable, Protractor was not waiting for tha... — committed to sjelin/angular.js by sjelin 8 years ago
- fix(ngRoute): make `route.resolve` count as a pending request Protractor users were having a problem where if they had asynchonous code in a route.resolve variable, Protractor was not waiting for tha... — committed to sjelin/angular.js by sjelin 8 years ago
- fix(ngRoute): make `route.resolve` count as a pending request Protractor users were having a problem where if they had asynchonous code in a route.resolve variable, Protractor was not waiting for tha... — committed to sjelin/angular.js by sjelin 8 years ago
- fix($route): make asynchronous tasks count as pending requests Protractor users were having a problem where if they had asynchonous code in a `route.resolve` or `route.resolveRedirectTo` variable, Pr... — committed to angular/angular.js by sjelin 8 years ago
- fix($route): make asynchronous tasks count as pending requests Protractor users were having a problem where if they had asynchonous code in a `route.resolve` or `route.resolveRedirectTo` variable, Pr... — committed to angular/angular.js by sjelin 8 years ago
- fix($route): make asynchronous tasks count as pending requests Protractor users were having a problem where if they had asynchonous code in a `route.resolve` or `route.resolveRedirectTo` variable, Pr... — committed to ellimist/angular.js by sjelin 8 years ago
@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.I have just updated to 1.2.0 today. And everything is magically working fine now without $timeout. Thank you to all the protractor contributors. @juliemr
Updates: OK. Sadly it was just my machine running a lot quicker after loading everything in memory. After I left this for some time and come back again, the same issue remains.
Thanks to @appsciences posting the stackoverflow link. To save a bit of time for other people, some one posted a word around on that page. Basically instead of relying on protractor to wait for the state/page to be resolved, wait for an element you expect to see.
I’m not one to +1 things, but this issue looked lonely.
edit: not an issue for me. had everything to do with fetching facebook login status in the promise. keep it up @juliemr and co