Reputation: 9397
I can't get my unit tests to work in Angular.js when I've defined my components in a module. Here is my unit test using Karma test runner with Jasmine. I've looked at several posts and it looks like this is the way to test module controllers. However, my test runner output says that 'module is not defined'. I'm not sure what I am missing. Do I need to configure something in karam.conf.js?
describe('bulkEditor factories', function() {
beforeEach(module('BulkEditor'));
it('should see the controller', inject(function($controller) {
expect($controller('GroupController'.toBeTruthy()));
}));
});
Here is a section from my karma.conf.js file that shows the list of files that get included:
files = [
JASMINE,
JASMINE_ADAPTER,
'https://ajax.googleapis.com/ajax/libs/angularjs/1.0.6/angular.min.js',
'app/js/app/**/*.js',
'test/*.spec.js'
];
Upvotes: 1
Views: 535
Reputation: 117370
The module
and inject
functions are defined in the angular-mocks.js
file. You can grab it from http://code.angularjs.org/ (ex.: http://code.angularjs.org/1.0.6/angular-mocks.js).
I must say that I've necer used Karma with files referenced via CDN but in any case angular-mocks.js is not deployed on CDN so you will have to get it from http://code.angularjs.org/
Upvotes: 2