0
I am getting the following error while running my test:
Error: [$injector:unpr] Unknown Provider: $scopeProvider <- $Scope
Logincontroller.js
(function(){
'use strict';
angular.module("app")
.controller('LoginController', LoginController);
LoginController.$inject = ['$scope', '$rootScope', '$controller', 'EntryPointService', 'initResolver'];
function LoginController($scope, $rootScope, $controller, EntryPointService, initResolver){
$controller('BaseController', { $scope: $scope });
var initialize = function(logged, stateName) {
if(logged && stateName === 'login') {
$scope.$state.go('master.modules');
}
if ($scope.$state.is('logout')) {
$scope.showLogoutPopup();
}
};
initialize($rootScope.operator_logged, $scope.$state.$current.name);
if([null, undefined].indexOf(initResolver) !== -1){
$scope.$state.go('init');
}
$scope.STCPAppVer = $scope.StcpUtilsService.getAppVersionToView();
Logincontroller.Spec
describe('LoginController test suite', function(){
beforeEach(angular.mock.module('app'));
var $scope, controller, state, base, rootScope, httpBackend, scope;
var fakeRequest = function(){
return;
};
beforeEach(angular.mock.inject(function($controller, $rootScope, $state,
$httpBackend, $scope){
state = {};
state.go = sinon.stub();
state.$current = {};
$scope = $rootScope.$new();
$scope.showLogoutPopup = sinon.stub();
$scope.$state = state;
$scope.$state.is = function(val){ return $scope.$state.$current.name === val; };
rootScope = $rootScope;
$scope.showLogoutPopup = sinon.stub();
base = $controller('LoginController', { $scope: $scope, $state: state
});
controller = $controller;
httpBackend = $httpBackend;
scope = $scope;
}));
it('function LoginController', function(){
});
What is missing? Why is this error occurring?
That’s all the code you have?
– Jéf Bueno
think your $Scope statement is giving conflict. var $Scope. Third line of Logincontroller.Spec
– CCastro
As Ccastro said, it must be this variable that is giving error in Scope, try to take the $Scope from the inject and change the variable name to another
– Julio Borges
The following error appeared when removing $Scope: Error: [$injector:unpr] Unknown Provider: initResolverProvider <- initResolver <- Logincontroller @Ccastro
– Aléxia
@LINQ no, I just sent a part.
– Aléxia
The following error appeared when removing $Scope: Error: [$injector:unpr] Unknown Provider: initResolverProvider <- initResolver <- Logincontroller @Julioborges
– Aléxia
What is this initResolver? something you wrote? If so, it, q must be an initResolver.js, has q be included there in your index.html
– CCastro
Ccastro it is already included but the error persists
– Aléxia
You removed $Scope from inject? If so, return it to inject, but do not declare on var.
– CCastro
@Ccastro the tips were followed but nothing changed
– Aléxia
If you want to upload the code to some git I take a look.
– CCastro