I had a similar problem when upgrading from angular from 1.3 to 1.4. In my case, I forgot to update angular-mocks from 1.3 to 1.4. I suspect that the mocking functionality was split into a separate module in the transition from 1.2 to 1.3, although I can not find the documentation confirming this. In this case, you would not need the angular-mocks for your original application, but you would need to add the dependency when updating.
You can fix this by adding "angular-mocks": "1.4.x" to the list of dependencies and a link to the installed file in the karma configuration. For completeness, here is a minimal example:
karma.conf.js :
module.exports = function (config) { 'use strict'; config.set({ basePath: '.', frameworks: ['jasmine'], files: [ 'node_modules/angular/angular.js', 'node_modules/angular-mocks/angular-mocks.js', '*.js' ], autoWatch: true, singleRun: false, browsers: ['Chrome'] }); };
package.json :
{ "name": "angular-inject-test", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "karma start karma.conf.js" }, "author": "", "dependencies": { "angular": "1.4.x", "angular-mocks": "1.4.x", "karma": "^0.13.x", "karma-cli": "^0.1.x", "karma-jasmine": "^0.3.x", "karma-chrome-launcher": "^0.2.x" } }
test.js :
angular.module('x', []) .factory('xyz', function () { "use strict"; return { getXYZDescription: function (value) { return value; } }; }); describe("Module: x.xyz", function () { "use strict"; describe("Factory: xyz", function () { var service; beforeEach(function () { module('x'); inject(function ($injector) { service = $injector.get("xyz"); }); }); it('Should echo input', function () { expect(service.getXYZDescription('abc')).toBe('abc'); }); }); });