[英]Equivalent of and.callThrough() in jest-preset-angular
Reading through this link i got to know that the equivalent of通过阅读此链接,我知道相当于
and.callFake
is mockImplementation
and and.callFake
是mockImplementation
和
and.returnValue
is mockReturnValue
. and.returnValue
是mockReturnValue
。
Similarly is there an equivalent of and.callThrough()
in jest-preset-angular?同样,在 jest-preset-angular 中是否有等效的and.callThrough()
?
This question may be really old, but tripped me up recently.这个问题可能真的很老,但最近让我绊倒了。
Jest, by default , will call the underlying function in a similar manner to .and.callThrough()
.默认情况下,Jest 将以与.and.callThrough()
类似的方式调用底层函数。
This is the opposite behaviour of Jasmine, which blocks the call to the underlying function unless .and.callThrough()
is specified.这是 Jasmine 的相反行为,它会阻止对底层函数的调用,除非指定了.and.callThrough()
。
To block the underlying call in Jest, call the mockImplementation()
function.要阻止 Jest 中的底层调用,请调用mockImplementation()
函数。
Jest by default will use Jasmine2 as test runner, and therefore you can use most (if not all) Jasmine methods. Jest默认将使用 Jasmine2 作为测试运行器,因此您可以使用大多数(如果不是全部)Jasmine 方法。
All of the ones you requested are in Jest available, and.callFake
, as well as and.returnValue
and and.callThrough
.您请求的所有内容都在 Jest 中可用, and.callFake
,以及and.returnValue
和and.callThrough
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.