Karma + angular-mocks TypeError: 'undefined' is not an object (evaluating 'angular.mock = {}')

You would need to include angular.js as well, then only angular.mocks will work else window.angular will be undefined.

 files: [ 
            'dom_munger.data.appjs',
            'path/to/angular.js', //<-- include angularjs
            'bower_components/angular-mocks/angular-mocks.js',
            'tests/spec/*.js'
        ],

update for 2017 and webpack 2 (but same angular<2)

  1. like @jlew said, angular-mocks expects angular on the window

  2. module reference is being replaces by webpack

So in tests you need an header like:

import angular from 'angular';
import 'angular-mocks/ngMock';

and replace each global module reference with angular.mock.module


angular-mocks.js presumes that angular.js has been included as well.