How to load ngScenario in E2E testing?

I want to use ngScenario to test my NG scripts. But I have no idea how to load it...

Besides loading the JS file using <script> tag, how to make it work? Please give a full sample.

There number of way to kick-start e2e tests execution, the most common one being a standalone HTML file or a test runner.

To trigger e2e tests execution via HTML file one would write something like:

<html lang="en">
<head>
    <title>End2end Test Runner</title>
    <script src="http://code.angularjs.org/1.0.3/angular-scenario.js" ng-autotest></script>
    <script src="app.scenario.js"></script>
</head>
<body>
</body>
</html>

Please note several things about this approach:

  • we need to load the angular-scenario.js file first. It includes all the necessary dependencies (including jQuery and AngularJS) so there is no need to include other files.
  • scenario tests need to be loaded afterwards (here those are located in app.scenario.js)
  • scenario execution is triggered by the presence of the ng-autotest attribute on the tag
  • you need to have this HTML file and other project files to be served via web server. Using the file:// protocol won't work here.

Another approach (probably preferred in reality) is to use a test runner and execute e2e tests as part of the continuous build. Using Karma is a popular option in the AngularJS community. A sample configuration for the Karma executing e2e tests can be found here: https://github.com/angular/angular-seed/blob/master/config/karma-e2e.conf.js