I have a angular where i want to test my controllers and services with karma and jasmine. I wrote some tests and they worked. Then i did some big changes to my angular project.
Now my tests are all failing and i can't figure out why. I commented everything out in my tests and just wanted to check if the $controller
service gets loaded. But not even this works.
My module definition:
angular.module('cManagement', [
'angular-multi-select',
'ngCookies',
'ui.router',
'ui.bootstrap',
'pascalprecht.translate',
'ngIdle'
])
Here is my test:
use strict';
describe("cManagement", function() {
beforeEach(module('cManagement'));
it('should exist', inject(function($controller){
}));
});
My Karma config:
module.exports = function(config){
config.set({
basePath : '',
reporters: ['progress', 'junit'],
files : [
'node_modules/angular/angular.js',
'node_modules/angular-cookies/angular-cookies.js',
'node_modules/angular-multi-select/dist/angular-multi-select.js',
'node_modules/angular-ui-router/release/angular-ui-router.js',
'node_modules/angular-ui-bootstrap/dist/ui-bootstrap.js',
'node_modules/angular-translate/dist/angular-translate.js',
'node_modules/angular-mocks/angular-mocks.js',
'assets/plugins/angular-idle/angular-idle.js',
'app/app.module.js',
'app/components/login/*',
'app/**/*'
],
singleRun : true,
frameworks: ['jasmine'],
browsers : ['PhantomJS'],
plugins : [
'karma-jasmine',
'karma-junit-reporter',
'karma-phantomjs-launcher'
],
junitReporter : {
outputDir: 'test_out',
userBrowserName: false
}
});
};
Here is the error i get:
INFO [karma]: Karma v0.12.37 server started at http://localhost:9876/ INFO [launcher]: Starting browser PhantomJS INFO [PhantomJS 2.1.1 (Linux 0.0.0)]: Connected on socket 7iIMKn57rTEEJqjikf2o with id 71013283 PhantomJS 2.1.1 (Linux 0.0.0) cManagement should exist FAILED /home/chris/IdeaProjects/campaignManagement/node_modules/angular/angular.js:4527:53 forEach@/home/chris/IdeaProjects/campaignManagement/node_modules/angular/angular.js:321:24 loadModules@/home/chris/IdeaProjects/campaignManagement/node_modules/angular/angular.js:4487:12 createInjector@/home/chris/IdeaProjects/campaignManagement/node_modules/angular/angular.js:4409:30 workFn@/home/chris/IdeaProjects/campaignManagement/node_modules/angular-mocks/angular-mocks.js:2799:60 PhantomJS 2.1.1 (Linux 0.0.0): Executed 2 of 2 (1 FAILED) (0.006 secs / 0.007 secs)
Every hint is appreciated.
inject
in a separatebeforeEach
block?beforeEach(inject(function($controller){ }));
– gmuraleekrishnause strict
– gmuraleekrishna