0

I'm trying to test my angular project and keep falling at the first hurdle. By just instantiating my module without even testing anything karma is throwing an error.

If I do include an it statement karma gives me an error saying 'Error: [$injector:modulerr]'. I'm using ngRoute in my project and I'm wondering if that has anything to do with it.

Here's my code, any suggestions on what could be wrong would be much appreciated.

angular.module('MyApp', ['ngRoute'])
.controller('HomeCtrl', ['loadArtists', function(loadArtists){
    var self = this;
    self.homeArtistsArray = [];
    self.homeArtistsArray = loadArtists; 
}])

-

describe('Practice', function(){
 beforeEach(module('MyApp'));
 var ctrl;
 beforeEach(inject(function($controller){
    ctrl = $controller('HomeCtrl');
 }))
 it('should do nothing',function(){
 }) 
});

-

files: [
    'jquery-1.11.3.min.js',
    'angular.js',
    'angular-mocks.js',
    'js/app.js',
    'js/appControllers.js',
    'js/appFactory.js',
    'js/testFile.js'
],

If ngRoute is the problem could you suggest somewhere to download it from.

1 Answer 1

2

You need to add angular-route.js to your karma configuration.

BTW, when debugging, you should use the not-minified angular.js file, so you get a full debug message with the error (here, modulerr).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.