protractor icon indicating copy to clipboard operation
protractor copied to clipboard

"angular never provided resumeBootstrap" pops up

Open donaldpipowitch opened this issue 11 years ago • 19 comments

Since some time we occasionally see "angular never provided resumeBootstrap" in our tests and can't figure out why. We have ng-app on <html> and use the latest stable version of Angular 1.2.x and the latest version of Protractor with Jasmine 1.

I can't really give more information, because it happens very randomly. We don't do manually bootstrapping or something like that. It worked without flaws for a while.

donaldpipowitch avatar Sep 04 '15 09:09 donaldpipowitch

I've seen this issue when manually bootstrapping, but haven't encountered it with ng-app. I don't think it would help but have you tried setting rootElement to html?

NickTomlin avatar Sep 04 '15 13:09 NickTomlin

Setting rootElement to html doesn't help sadly.

donaldpipowitch avatar Sep 07 '15 09:09 donaldpipowitch

It's really hard to say anything without more info or something repeatable that I can debug. Please let me know if you find anything more we can use to investigate.

juliemr avatar Sep 22 '15 23:09 juliemr

I get this error message, too. The ng-app directive is in the body element. So everything should work normally.

For more information about my problem, please see http://stackoverflow.com/questions/32719042/angular-never-provided-resumebootstrap

Thanks in advance for helping!

lehnerchristian avatar Sep 24 '15 19:09 lehnerchristian

@juliemr @chrilehner90 @davideast I think the snyc with angular is not ok. I can't use protractor to test my app. I always get this error:

Failed: Error while waiting for Protractor to sync with the page: "[ng:test] no injector found for element argument to getTestability\nhttp://errors.angularjs.org/1.4.5/ng/test"

In real life applications need often to get some API data before they will run. In my case I need some API data before the app is in the configuration phase. For that reason I created a simple script which requests the API data, before angular and the app is loaded. If I have the results from the API I load angular and the app files which are merged within one file -> merged with requires js. I set the window name to window.name = 'NG_DEFER_BOOTSTRAP!'; and call the angular.resumeBootstrap. I think this should be supported by protractor. If I got this right, setting the name causes angular to pause bootstrapping the application until the resume function is called.

If I start a protractor test the application loads directly and is already showing up. But I still get the error -> Failed: Error while waiting for Protractor to sync with the page: "[ng:test] no injector found for element argument to getTestability\nhttp://errors.angularjs.org/1.4.5/ng/test"

And I have a ng-app attribute within my html file.

I think there is something going wrong within protractor. How can it be that the page is already rendered before I get this error? I tried a browser.sleep() and also a browser.waitForAngular();

Karpo72 avatar Sep 29 '15 10:09 Karpo72

This might not be the solution to everyone's problems, but if you're using Browsersync, read on.

Solution:

Add scrollRestoreTechnique: 'cookie' to your browsersync config.

Background:

Browsersync (>=2.7.11) restores your scroll position when it refreshes and it stores that information in one of two places - window.name (the default) or a cookie.

Unfortunately, Protractor uses an Angular feature called Deferred Bootstrap that uses window.name and conflicts with BrowserSync. From the AngularJS Docs:

This feature enables tools like Batarang and test runners to hook into angular's bootstrap process and sneak in more modules into the DI registry which can replace or augment DI services for the purpose of instrumentation or mocking out heavy dependencies.

If window.name contains prefix NG_DEFER_BOOTSTRAP! when angular.bootstrap is called, the bootstrap process will be paused until angular.resumeBootstrap() is called.

If Browsersync overwrites that window.name value before it gets caught by Angular, Angular will not defer its Bootstrap and Protractor will subsequently not be able to find the resumeBootstrap function because it won't exist.

Telling Browsersync to use a cookie instead of window.name resolves the conflict.

benjaminkitt avatar Oct 09 '15 04:10 benjaminkitt

Well, this could be the problem in our case!

donaldpipowitch avatar Oct 09 '15 06:10 donaldpipowitch

@benjaminkitt Thanks for your solution, but I think there is something buggy in protractor. I changed my grunt release processes to remove requirejs and I changed the way how the application gets loaded. Now the application gets automatically bootstraped by angualr without resumeBootstrap. And I still don't get the tests to work if sync is enabled. Now protractor keeps telling that it can't find the ng-app, but I have one in my html file now. I believe it has some thing to do with the implementation of protractor. I also installed some chrome add-ons for testing my app. Some of them are working fine and reconize my app others of them are not able to find my app. For me its looks like the same issues.

Karpo72 avatar Oct 09 '15 06:10 Karpo72

@benjaminkitt after hours of searching why e2e sometimes fails (3 of 9 tries) with the message "angular never provided resumeBootstrap" I found your hint "scrollRestoreTechnique: cookie" and ... BINGO it has solved my e2e test troubles. THANK YOU!

cyberflohr avatar Oct 13 '15 09:10 cyberflohr

@cyberflohr Glad it helped!

Happily, BrowserSync's @shakyShane has fixed this issue in BrowserSync 2.9.11. See https://github.com/BrowserSync/browser-sync/issues/808

benjaminkitt avatar Oct 13 '15 13:10 benjaminkitt

I had the same issue, updating browser-sync solved the problem for me too.

seniorpreacher avatar Nov 09 '15 11:11 seniorpreacher

I am getting the same issue - manual bootstrap - angular 1.2.x, protractor 2.x. I am not using browser-sync.

    Failed: Angular could not be found on the page http://localhost:8080/prod/dondeDist.html : angular never provided resumeBootstrap

when I set browser.ignoreSynchronization = true; I don't get this error, but that causes other problems and I have to add lots of timeouts in my tests to make them work. @juliemr anyway you can help me with this?

aaani avatar Apr 07 '16 19:04 aaani

Same error message and issue than @aaani, using protractor 3.2.2 and angular 1.2.29, and no browser-sync. Failed: Angular could not be found on the page http://localhost:8000/index.html : angular never provided resumeBootstrap

'use strict';
describe( 'e2e tests', function()
{
  beforeEach(function()
  {
    browser.get('index.html');
    browser.ignoreSynchronization = true;
  });
  describe( '- Page title', function()
  {
    it( 'should have a title', function()
    {
      expect(browser.getTitle()).toEqual('Page title');
    });
  });
});

Setting browser.ignoreSynchronization = true;, or not, didn't helped. Setting framework protrator configuration option to jasmineor jasmine2 didn't helped too.

app.js wrapped with:

window.angular && (function ( angular )
{
  'use strict';

  /**
   * @ngdoc overview
   * @name xxx
   * @description xxx
   */
  var xxx = angular.module( 'xxx', [ 'ngRoute', 'ngCookies', 'pascalprecht.translate', 'tmh.dynamicLocale', 'ngIdle' ]);
...
})( angular );

JeanPerriault avatar Apr 08 '16 08:04 JeanPerriault

Updated Protractor to 3.2.2 (also running Angular 1.2.16) and started getting the "angular never provided resumeBootstrap" as well.

@aaani 's work-around of setting browser.ignoreSynchronization = true; has stopped the timeout issue, but it prevents the tests from running properly (and passing).

Note: also using manual bootstrapping

pinkninjajess avatar Apr 08 '16 19:04 pinkninjajess

For information, as stated in https://github.com/angular/protractor/issues/3115, rolling back to protractor 3.1.1 resolved this issue.

JeanPerriault avatar Apr 14 '16 12:04 JeanPerriault

Downgrading to Protractor 3.1.1 also solved this for me.

SuneRadich avatar Apr 26 '16 09:04 SuneRadich

This issue is kind of a conglomeration of a bunch of old issues over time. I don't think it's providing any use to keep it open. For the latest issue (which was not a flake, just happened all the time), Protractor 3.3.0 should fix it. As for the BrowserSync issues, I don't have much knowledge about this and hope that their update helps.

If you are seeing a specific new issues with the latest protractor, please open up a new issue.

juliemr avatar Apr 26 '16 16:04 juliemr

Thanks @juliemr, using protractor 3.3.0 worked for me.

stelish avatar Apr 26 '16 18:04 stelish

I got the same problem. The error "angular never provided resumeBootstrap" randomly occurred. I did not change the angular and protractor version, and this problem just happened since some day. Perhaps some changes in my page caused this. I tried:

  1. Set rootElement=html, did not work.
  2. Downgraded Protractor to 3.1.1 or upgraded to 3.3.0, did not work.
  3. Set longer more timeout as browser.get(url, 30 * 1000);, did not work.
  4. I used browser.sleep(20 * 1000) before the first browser.get(), it works.
  5. Finally I used browser.get(url).then(null,browser.get(url)); instead of the first browser.get() in my test, it works. Hope this helps someone facing same problem.

daxianji007 avatar May 12 '16 04:05 daxianji007