Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS 1.2 ngRoute unit test error

Tags:

angularjs

I upgraded to angularjs v1.2 and now my unit tests are failing because of ngRoute. I followed the changes here http://docs.angularjs.org/api/ngRoute and included the new script in my index.html file as well as loading the module and my app works fine:

--index.html

<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-route/angular-route.js"></script>

--app.js

var socketwizModule = angular.module('socketwizApp', ['ngRoute']);

But my tests fail with the following error.

I tried the following couple of things but nothing seems to work, any ideas?

beforeEach(module('socketwizApp', ['ngRoute']));

And

beforeEach(module('ngRoute'));
beforeEach(module('socketwizApp'));
like image 401
Ricky Nelson Avatar asked Aug 30 '26 16:08

Ricky Nelson


1 Answers

You said you fixed your code but you didn't say that you fixed your tests. Assuming that you use Karma for unit tests (as I do), did you make sure that your conf.js file includes it here?

// list of files / patterns to load in the browser
files: [
  'app/components/angular/angular.js',
  'app/components/angular-mocks/angular-mocks.js',
  'app/scripts/**/*.js',
  'test/**/*Spec.js'
],

Because if not then it won't be available to your unit tests because (again, if they're like mine) they don't use the index.html to get the list of JavaScript to include.

like image 186
John Munsch Avatar answered Sep 01 '26 08:09

John Munsch



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!