Using angular.mock.inject in karma gives "TypeError: Cannot read property '$injector' of null"
I honestly don't know if this is the fix at all, and it probably only works for Mocha, but I was running into the same thing and I changed the first beforeEach bit to this:
beforeEach(function() { module('myApp'); });
and it seems to be working better. It seems like the timing of the angular.mocks.module call works out better if you let the testing framework (mocha in my case) have a wrapped version of the method.
I commonly run into this error when the issue is simply an un-closed )
or }
Outside of that, an approach to debug the issue might be to simplify until the problem goes away. That is, start removing large portions of code, a bit at a time, until you've "binary-searched" for the issue.
I have the same issue.
In my case, this error occurs when you use angular 1.0.8 and angular-mocks 1.0.8 with the newer version of Jasmine (2.0.0+, not so new actually)
angular-mock assumes some internal variable in Jasmine and it doesn't exist anymore in the new version.For more detail, see this one https://github.com/angular/angular.js/issues/5632.
The solution is either upgrade your Angular (not possible in my case) or downgrade your Jasmine.
If you use Grunt to run karma, downgrade your karma-jasmine to version '~0.1.0' will fix this issue. This version includes jasmine, so you should also remove 'jasmine-core' from your devDependencies. The set of devDependencies below worked for me.
"devDependencies": { "grunt-karma": "^0.10.1", "karma": "^0.12.31", "karma-chrome-launcher": "^0.1.7", "karma-coverage": "^0.2.7", "karma-jasmine": "~0.1.0", "karma-junit-reporter": "^0.2.2", "karma-phantomjs-launcher": "^0.1.4", "phantomjs": "^1.9.15",}