I am currently upgrading an Angular 1.2.x application to 1.5.5. After upgrading it, the application itself is still working fine. Unfortunately my servicetests are failing with (e.g) the errormessage:
Error: [$injector:unpr] Unknown provider: storeProvider <- store <- secondService
As far as i understand the previous errormessage it is telling me, that within the testscope there is no 'secondService' available. I considered that to be the
Let's say 'firstService' must be mocked. The second service is so simple that it is not needed to mock it.
describe('mainService', function () {
[...]
beforeEach(module('app.myApp', function($provide) {
$provide.value('$state', stateMock);
$provide.value('firstService', firstServiceMock);
//following line is needed in Angular 1.3 and greater,
//if i am running it on angular 1.2 without the line it is working
$provide.value('secondService', secondServiceMock); }));
beforeEach(inject(function ($injector) {
mainService = $injector.get('mainService');
How can i inject the original 'secondService' into my unittest, as i do not want to mock every service that this servicetest is depending on.
Please correct me if i am wrong, as i understood it is an issue with scoping https://docs.angularjs.org/guide/migration#migrating-from-1-2-to-1-3. But this more looks like it is related to controllers and not to services.
If it is, then how can i inject it? I also could not figure out a way to use the deprecated mentioned '$controllerProvider.allowGlobals();' in the testcontext. The Class:
(function () {
'use strict';
angular.module('app.myApp').factory('mainService', mainService);
/* ngInject */
function mainService($state, firstService, secondService,){...}