Lets have a clean Karma
1 min readDec 14, 2015
Setup Karma npm modules
>> npm install karma karma-jasmine karma-chrome-launcher --save-dev
// optional
// sudo npm install -g karma-cli
Initialize Karma config
>> karma init karma.config.js
In the config.js, make sure the angular files are loaded from the right path example as such
files: [
‘../../node_modules/angular/angular.js’,
‘../../node_modules/angular-mocks/angular-mocks.js’,
‘../../app/static/dist/static/js/*.js’,
‘**/*.tests.js’
],
Sample Test
‘use strict’;describe(‘TopMostController’, function () {
beforeEach(module(‘app’));
var topMostCtrl;
describe(‘TopMostController’, function () {
it(‘must have animations enabled’, inject(function ($controller) {
var $scope = {};
topMostCtrl = $controller(‘TopMostController’, { $scope: $scope });
expect(topMostCtrl.animationsEnabled).toBe(true);
}));
});
});
Start the karma runner:
>> karma start karma.config.js
// with --debug flag to get more information