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