Jasmine spec timeout when running Protractor tests on a remote selenium server
Asked Answered
T

1

7

I have Protractor tests that run fine locally (directConnect: true), but when I try to run them on a remote Selenium server (Grid), I always get the following message.

A Jasmine spec timed out. Resetting the WebDriver Control Flow.

Looking at the Failures, the Message and Stack display the following for all my test cases:

Message:
  Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
Stack:
  Error: Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
    at Timer.listOnTimeout (timers.js:92:15)

I've tried a number of things, such as increasing the jasmine timeout interval, adding earlier timeouts such as getPageTimeout and allScriptsTimeout to the conf, but it still throws the jasmine timeout error. The log shows the following error:

00:03:18.328 INFO - Done: [execute async script: try { return (function (rootSelector, ng12Hybrid, callback) {
var el = document.querySelector(rootSelector);

try {
  if (!ng12Hybrid && window.getAngularTestability) {
    window.getAngularTestability(el).whenStable(callback);
    return;
    }
  if (!window.angular) {
    throw new Error('window.angular is undefined.  This could be either ' +
      'because this is a non-angular page or because your test involves ' +
      'client-side navigation, which can interfere with Protractor\'s ' +
      'bootstrapping.  See http://git.io/v4gXM for details');
}
  if (angular.getTestability) {
  angular.getTestability(el).whenStable(callback);
}   else {
      if (!angular.element(el).injector()) {
    throw new Error('root element (' + rootSelector + ') has no injector.' +
       ' this may mean it is not inside ng-app.');
  }
  angular.element(el).injector().get('$browser').
      notifyWhenNoOutstandingRequests(callback);
}
} catch (err) {
callback(err.message);
}
}).apply(this, arguments); }
catch(e) { throw (e instanceof Error) ? e : new Error(e); }, [body, false]])

I know for sure my app is angular and it runs successfully when running locally. I've tried setting

browser.ignoreSynchronization = true

, as well as setting the

rootElement='html#ng-app' 

in the conf (bc my ng-app is not in the body, but rather inside the html tag). Framework is set to 'jasmine' although I've tried 'jasmine2' but neither seems to make any difference. On the remote server, I am able to get firefox to start up, and the UI shows me the started firefox session. However it just sits there until the timeout occurs. Any input would be appreciated!

Tigon answered 27/9, 2016 at 0:16 Comment(0)
P
2

Jasmine needs to know it is running an async process and when that process is supposed to be complete (to proceed with any other test you may be running).

This is obtained by passing done to the Jasmine async method callback and calling done() when the async operation is resolved.

If you don't call done() Jasmine shows a timeout error. I think this should solve your problem.

More info here: Mocking ngResource in Angular unit tests.

Hope this helps!

Pringle answered 16/10, 2016 at 8:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.