저는 일반적으로 각진과 테스트에 익숙하지 않습니다. 나는 다른 것을 테스트하려고 시도하기 전에 객체가 정의되어 있는지를 확인하는 기본 테스트를 설정하려고합니다. 나는 시도하고이 오류가 표시되지 않습니다 다른 테스트 파일에 대한 기본적인 테스트를하지만 때공장 테스트를하고 있는데 문제가 있습니다.
Error: [$injector:unpr] Unknown provider: $stateParamsProvider <- $stateParams <- Form
:
는이 오류를 얻고있다.
공장
angular.module('omnibyte_inspect_web.objects')
.factory('CommonQuestions', ['common_questions_factory', 'Form', '$rootScope',
function (common_questions_factory, Form, $rootScope) {
// Ctor
function CommonQuestions(data) {
var keys = Object.keys(data);
for (var i = 0; i < keys.length; i++) {
this[keys[i]] = data[keys[i]];
}
};
CommonQuestions.prototype.Select = function() {
this.Id = guid();
Form.CurrentForm().AddCommonQuestion(angular.copy(this));
};
CommonQuestions.prototype.Remove = function() {
common_questions_factory.delete(this.Id).then(function() {
window.location.reload();
});
};
// Static Methods
CommonQuestions.Current = function() {
return $rootScope.config_info;
};
CommonQuestions.GetAll = function (callback) {
common_questions_factory.get().then(function (data) {
var collection = [];
for (var i = 0; i < data.length; i++) {
collection.push(new CommonQuestions(data[i]));
}
callback(collection);
});
};
return CommonQuestions;
}]);
테스트 파일
describe('CommonQuestions Test', function() {
beforeEach(module('omnibyte_inspect_web.objects'));
var common_questions_factory, $rootScope, CommonQuestions, Form;
beforeEach(inject(function (_common_questions_factory_, _Form_, _$rootScope_, _CommonQuestions_) {
common_questions_factory = _common_questions_factory_;
Form = _Form_;
$rootScope = _$rootScope_;
CommonQuestions = _CommonQuestions_;
spyOn(CommonQuestions, 'GetAll');
spyOn(common_questions_factory, 'get');
spyOn(CommonQuestions, 'Current');
}));
it('should have CommonQuestions be defined', function() {
expect(CommonQuestions).toBeDefined();
});
});
편집
여러 파일에서 동일한 문제를 가졌하지만 내 서식 파일에서 오는 것 같다 . 어느 것 :
양식
angular.module('omnibyte_inspect_web.objects')
.factory('Form', ['forms_factory', 'authentication_service', 'common_questions_factory', 'formdata_factory', 'missinginformation_factory', '$stateParams', 'Question', 'LocationContact', '$rootScope', '$ionicPopup', '$state',
function (forms_factory, authentication_service, common_questions_factory, formdata_factory, missinginformation_factory, $stateParams, Question, LocationContact, $rootScope, $ionicPopup, $state) {
두 번째 편집
내 테스트 파일에이 모듈 beforeEach(module('ui.router'));
퍼팅 후 내가 얻을 :
Error: [$injector:unpr] Unknown provider: $ionicPopupProvider <- $ionicPopup <- Form
에이 모듈 beforeEach(module('$ionic'));
퍼팅 후 내 테스트 파일에 오류가 발생합니다. 그러나, 나는 정의되지 않은 것으로 기대된다. 이 테스트는 다른 모든 파일에서 작동했습니다.
"해결"을 추가하지 마십시오. 문제가 해결 된 대답을 수락하십시오, 이건 당신이 될 수 있습니다 – Liam
감사합니다. – Cody