我在一个TypeScript项目中使用Angular.js,并使用Jasmine进行测试。当我使用spyOn在对象上模拟一个方法时,Jasmine用一个具有calls属性的函数替换该方法,例如,您可以执行thing.method.calls.count()。TypeScript编译器不知道方法上的calls属性,并给出编译器错误:
property 'calls' does not exist on type '() =&
我想提供我自己的函数来替换工厂,我也希望能够使用.and.callThrough()来使用原始的功能。我遇到的主要问题是无法将工厂插入模拟模块语句。original functionality is gone at this point because I'm overriding it with $provide mockF