相当于 jest-preset-angular 中的 and.callThrough()

rad*_*ead 4 angular angular-test jest-preset-angular

通过阅读此链接,我知道相当于

and.callFakemockImplementation

and.returnValuemockReturnValue

同样,and.callThrough()在 jest-preset-angular 中是否有等价物?

blo*_*ish 6

这个问题可能真的很老,但最近让我绊倒了。

默认情况下,Jest将以与 类似的方式调用底层函数.and.callThrough()

这是Jasmine的相反行为,除非.and.callThrough()指定,否则它会阻止对底层函数的调用。

要在 Jest 中阻止底层调用,请调用该mockImplementation()函数。


wth*_*tho -3

大多数与 Jasmine2 相关的方法不再可用。有关如何通过监视方法进行调用等更多信息,请参阅 Jest 文档。


过时的答案

默认开玩笑将使用 Jasmine2 作为测试运行器,因此您可以使用大多数(如果不是全部)Jasmine 方法。

您请求的所有内容都可以在 Jest 中找到,and.callFake、 以及and.returnValueand.callThrough