Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

"angular never provided resumeBootstrap" pops up #2473

Closed
donaldpipowitch opened this issue Sep 4, 2015 · 19 comments
Closed

"angular never provided resumeBootstrap" pops up #2473

donaldpipowitch opened this issue Sep 4, 2015 · 19 comments

Comments

@donaldpipowitch
Copy link

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.

@NickTomlin
Copy link
Contributor

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?

@donaldpipowitch
Copy link
Author

Setting rootElement to html doesn't help sadly.

@juliemr
Copy link
Member

juliemr commented Sep 22, 2015

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.

@lehnerchristian
Copy link

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!

@Karpo72
Copy link

Karpo72 commented Sep 29, 2015

@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();

@benjaminkitt
Copy link

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.

@donaldpipowitch
Copy link
Author

Well, this could be the problem in our case!

@Karpo72
Copy link

Karpo72 commented Oct 9, 2015

@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.

@cyberflohr
Copy link

@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!

@benjaminkitt
Copy link

@cyberflohr Glad it helped!

Happily, BrowserSync's @shakyShane has fixed this issue in BrowserSync 2.9.11. See BrowserSync/browser-sync#808

@seniorpreacher
Copy link

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

@aaani
Copy link

aaani commented Apr 7, 2016

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?

@JeanPerriault
Copy link

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 );

@pinkninjajess
Copy link

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

@JeanPerriault
Copy link

For information, as stated in #3115, rolling back to protractor 3.1.1 resolved this issue.

@SuneRadich
Copy link

Downgrading to Protractor 3.1.1 also solved this for me.

@juliemr
Copy link
Member

juliemr commented Apr 26, 2016

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 juliemr closed this as completed Apr 26, 2016
@stelish
Copy link

stelish commented Apr 26, 2016

Thanks @juliemr, using protractor 3.3.0 worked for me.

@daxianji007
Copy link

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests