AngularJS: running e2e tests using karma

I want to run Jasmine e2e tests using KarmaJS (0.9.2). I use Google Closure with AngularJS (1.0.7) on Windows 7. When I start working with karma using karma start config\karma-e2e.js , everything works fine (the browser goes to fix the page), but it does not perform my tests (stops on the "browser").

File config\karma-e2e.js :

 basePath = '../'; frameworks = ['ng-scenario']; files = [ 'tests/e2e/**/*.js' ]; autoWatch = true; singleRun = false; browsers = ['Chrome']; urlRoot = '/__karma/'; proxies = { '/': 'http://localhost:8080/' } plugins = [ 'karma-ng-scenario' 'karma-chrome-launcher' ] 

Testing source ( tests\e2e\scenarios.coffee ):

 describe 'Intro page view', -> it 'has hello world message', -> browser().navigateTo '/app/client/' expect(element('#text').text()).toBe 'Hello World' 

I use html5Mode routes, angular is loaded manually using angular.bootstrap , all my coffee scripts are compiled by the IDE, and I don't see errors in the browser console or on the command line. So how do I do this? Am I doing something wrong?

Thanks!

+4
source share
1 answer

I solved this problem. The angular script seems to require the ng-app directive, which is at least weird (or is this a bug). So I added the ng-app attribute to the body after calling App.bootstrap () on the index page. Now everything is working fine.

 <script type="text/javascript"> App.bootstrap(); document.body.setAttribute('ng-app', 'App'); </script> 
+6
source

Source: https://habr.com/ru/post/1482760/