How to inject ngRoute into Jasmine / Karma AngularJS unit test? <p>I'm trying to get a basic unit test example working. It all works fine with this app.js</p> <pre><code>var whapp = angular.module('whapp', []) .filter('reverse',[function(){ return function(string){ return string.split('').reverse().join(''); } }]); </code></pre> <p>and this spec.js</p> <pre><code>describe('Filters', function(){ //describe your object type beforeEach(module('whapp')); //load module describe('reverse',function(){ //describe your app name var reverse, rootScope; beforeEach(inject(function($filter){ //initialize your filter reverse = $filter('reverse',{}); })); it('Should reverse a string', function(){ //write tests expect(reverse('rahil')).toBe('lihar'); //pass }); }); }); </code></pre> <p>with this karma files config</p> <pre><code>files: [ 'node_modules/angular/angular.js', 'node_modules/angular-mocks/angular-mocks.js', 'node_modules/angular-mocks/angular-route/angular-route.js', 'node_modules/angular-mocks/angular-ui-router/release/angular-ui-router.js', 'app/js/*.js', 'tests/*.js' ] </code></pre> <p>The problem occurs when I try to inject ngRoute into my module in app.js like so</p> <pre><code>var whapp = angular.module('whapp', ['ngRoute']) .filter('reverse',[function(){ return function(string){ return string.split('').reverse().join(''); } }]); </code></pre> <p>In which case I get the following error in karma [UPDATE: this error occurs even if I don't load the angular-mock.js library into karma as shown above]</p> <pre><code>TypeError: undefined is not a constructor (evaluating 'reverse('rahil')') in tests/spec.js (line 9) </code></pre> <p>So... how do I inject ngRoute into spec.js correctly? I've tried a variety of things, none of which worked.</p>