I am facing an issue while writing unit tests using Karma + Jasmine. The problem arises with angular-mocks when I run grunt test, resulting in the following error message:
PhantomJS 1.9.8 (Mac OS X) ERROR TypeError: 'undefined' is not an object (evaluating 'angular.mock = {}') at /Users/danielbogart/Documents/coding/work/AexNav/bower_components/angular-mocks/angular->mocks.js:17 Chrome 39.0.2171 (Mac OS X 10.9.4) ERROR Uncaught TypeError: Cannot set property 'mock' of undefined at /Users/danielbogart/Documents/coding/work/AexNav/bower_components/angular-mocks/angular->mocks.js:17
This is my Gruntfile karma configuration:
karma: {
options: {
frameworks: ['jasmine'],
files: [
'dom_munger.data.appjs',
'tests/spec/*.js',
'bower_components/angular-mocks/angular-mocks.js'
],
logLevel: 'ERROR',
reporters: ['mocha'],
autoWatch: false, //watching is handled by grunt-contrib-watch
singleRun: true
},
all_tests: {
browsers: ['PhantomJS', 'Chrome']
},
during_watch: {
browsers: ['PhantomJS']
}
}
Any help will be greatly appreciated. Thanks!