Question

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?

Was it helpful?

Solution

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

}));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top