Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

can't test Angular app initialized by angular.bootstrap(document) #422

Closed
dai-shi opened this Issue · 6 comments

4 participants

@dai-shi

I have an app which is initialized by angular.bootstrap() as
described as Manual Initialization in http://docs.angularjs.org/guide/bootstrap

 <script>
   angular.element(document).ready(function() {
     angular.bootstrap(document);
   });
 </script>

How can I run the e2e test for the app?

@vojtajina

The scenario runner needs to be able to find the root element, put ng-app on it, so you need to bootstrap document.body or something (because you can't put a css class on document):

angular.bootstrap(document.body);
document.body.className = document.body.className + ' ng-app';
@vojtajina vojtajina closed this
@dai-shi

This works. Thanks.

@kdekooter

but why? what is the difference putting ng-app in your static html?

@dai-shi

Because I want to control the bootstrap timing from JavaScript.
Please visit: http://github.com/dai-shi/connect-prerenderer
Hopefully, you get the idea: First, the HTTP server returns a pre-rendered HTML page,
and based on a certain request (ex. user clicks, or timer), the angular bootstrap begins.

@kdekooter

Thanks!

@tapmantwo

If it helps, I've created a preprocessor for Karma that will inject the ng-app fix mentioned by vojtajina.

Code: https://github.com/tapmantwo/karma-ng-bootstrap-fix-preprocessor
npm: https://www.npmjs.org/package/karma-ng-bootstrap-fix-preprocessor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.