2

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'));
Ricky Nelson
  • 876
  • 10
  • 24

1 Answers1

9

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.

John Munsch
  • 19,530
  • 8
  • 42
  • 72
  • Thanks John, I'm still sort of new to karma and jasmine and did not realize that was how it was configured. I made the incorrect assumption that it was using index.html. So now that I have added the angular-route.js script to the files list it works as expected. – Ricky Nelson Sep 14 '13 at 17:40