0
일부 unitTests하고 있는데 내 시나리오는 다음과 같습니다. 나는 50 가지 테스트를 서비스 함수에 대한 호출이 동일해야하지만, 하나의 단일 테스트에서는 원래 메소드를 호출 할 수 있다면 매우 유용 할 것입니다. and.callThrough로 시도했지만 제대로 작동하지 않습니다. 나는 스파이를 무시하려고 노력하고 있지만 나는 할 수 없다. 내가 뭘 잘못하고있어?CallThrough 주입 스파이
beforeEach(inject(function($controller, _myService_){
spyOn(_myService_, 'getSomeData').and.callFake(function(data, params){
return dummyData;
});
createController = function() {
return $controller('MyCtrl',{
$uibModalInstance: modalInstance,
myService: _myService_,
injectedData: injectedData
});
};
}));
이것은 테스트 사례입니다.
it('My test case', function(){
controller = createController();
controller.myService.getSomeData = jasmine.createSpy().and.callThrough()
});
저는 jasmine 2.0을 사용하고 있으며이 테스트 케이스는 계속 callFake 함수를 호출하고 있습니다.
감사
내 문제를 해결 주셔서 감사합니다 :) – acostela