I need to use the angularjs mock inject method within Jasmine to inject a service with dots in the name. I tried to do add string identifiers but the inject method does not seem to support this. This is not possible:

beforeEach(inject(['$rootScope','MyApp.Factories.TestFactory', 
    function ($rootScope, testFactory) {

    //doSomeThing

}]));

Is there another way to handle this?

有帮助吗?

解决方案

I haven't tested this, but you can probably get it from the $injector yourself. Something like this:

beforeEach(inject(function($rootScope,$injector) {
    var testFactory = $injector.get('MyApp.Factories.TestFactory');
    //doSomeThing

}));
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top