angularjs - Protractor test timing out after login -


working on first angular app, , writing first protractor test check login functionality. authentication using ng-token-auth , i'm using ui-router. suspect issue test not catching redirect i've tried various workarounds , cannot work.

here's basic routing , redirection code:

angular   .module('testangularapp', [     'nganimate',     'ngcookies',     'ngresource',     'ui.router',     'ngsanitize',     'ng-token-auth'   ])   .config(function ($stateprovider, $urlrouterprovider, $authprovider, $locationprovider) {     $locationprovider.html5mode(true).hashprefix('!');     $urlrouterprovider.otherwise('/');      $authprovider.configure({       apiurl: 'http://backend.dev'     });      $stateprovider       .state('index', {         url: "/",         templateurl: 'views/main.html',         controller: 'mainctrl',         controlleras: 'main'       })       .state('app', {         url: '/app',         abstract: true,         template: '<ui-view/>',         resolve: {           auth: function($auth, $state) {             return $auth.validateuser().catch(function() {               $state.go('index');             });           }         }       })       .state('app.dashboard', {         url: '/dashboard',         templateurl: 'views/dashboard.html',         controller: 'dashboardctrl',         controlleras: 'dashboard'       });   })   .run(function($rootscope, $location, $state) {     $rootscope.$on('auth:login-success', function() {       $state.go('app.dashboard');     });   }); 

so on rendering main page, fill in login details, click button, , use $state.go head app dashboard. protractor test follows:

describe('budget', function() {   describe('authentication', function() {     beforeeach(function() {       browser.get('http://localhost:9000');     });      it('should log in , redirect dashboard', function(done) {       element(by.model('loginform.email')).sendkeys('someone@somewhere.com');       element(by.model('loginform.password')).sendkeys('password');       element(by.id('login-button')).click();        expect($('h3.title').gettext()).toequal('welcome');     });   }); }); 

fairly straightforward. error is:

     timed out waiting protractor synchronize page after 11 seconds. please see https://github.com/angular/protractor/blob/master/docs/faq.md. following tasks pending: - $timeout: function () {                     return _this.validateuser({                       config: _this.getsavedconfig()                     });                   } 

notably test fails, works fine. in chrome window pops up, logging in works, browser redirects , see welcome text.

things i've tried...

  • browser.ignoresynchronization = true; in test
  • browser.wait(...for element...) in test
  • $location.path instead of $state.go
  • adding browser.waitforangular() test
  • probably random other stack overflow suggestions i've found , forgotten

any ideas?

finally figured out. reference seems issue ng-token-auth using $timeout variable in of it's code confuses progractor. fixed in pr:

https://github.com/lynndylanhurley/ng-token-auth/pull/196

and verified fixed in 0.29beta1 release.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -