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()
});
我使用的是茉莉花2.0,測試用例不斷調用callFake函數。
感謝
謝謝你,解決了我的問題:) – acostela