Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed: Timed out waiting for asynchronous Angular tasks to finish after 11 seconds

I would like to end-to-end test our angular 2 application using Protractor, but I'm stuck with the message:

"Failed: Timed out waiting for asynchronous Angular tasks to finish after 11 seconds."

My conf file.

exports.config = {
  directConnect: true,
  specs: ['spec.js'],

  // For angular2 tests
  useAllAngular2AppRoots: true,
}

Chrome is opened, and the website is also opened, then nothing happens till the the timeout.

When disabling the synchronisation (using browser.ignoreSynchronization = true; ), it's OK. But I'm loosing the "automatic waiting" feature, one of the main advantages of using Protractor.

The application is fully based on angular 2. So why this does not work?

Our developers told me that we are not polling (one of the possible cause according Protractor documentation). By the way, we are using websocket architecture. I don't know if there's a link.

Actually, I don't know how to troubleshoot this issue at all.

Could someone help, please?

like image 681
Tibeben Avatar asked Dec 22 '16 14:12

Tibeben


3 Answers

Your guess is right. This error would occur when their are any outstanding tasks running in your angular2 application.

Yes, the most common reason is when application continuously polls $timeout or $http, Protractor will wait indefinitely and time out. But this can also occur in scenarios where App takes more than 11 seconds

Please refer here for more information on different timeouts

the default timeout value is 11 seconds. You can change this by adjusting the below value in config.js and try and see if you are still seeing the issue

  /**
   * The timeout in milliseconds for each script run on the browser. This
   * should be longer than the maximum time your application needs to
   * stabilize between tasks.
   */
  allScriptsTimeout?: number;
like image 175
AdityaReddy Avatar answered Nov 12 '22 01:11

AdityaReddy


Temporarily enabling browser.ignoreSynchronization fixes it, as reported in an answer here.

browser.ignoreSynchronization = true;

(code that throws the error)

browser.ignoreSynchronization = false;
like image 23
emery Avatar answered Nov 12 '22 02:11

emery


Modify the test case and put browser.waitForAngularEnabled(false); after the first click, should work.

However, recommended method can be overriding the default timeout in your conf.js file as allScriptsTimeout: 110000

like image 2
Saikat Avatar answered Nov 12 '22 02:11

Saikat