简体   繁体   English

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

[英]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.callFakemockImplementation

and.returnValue is mockReturnValue . and.returnValuemockReturnValue

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.returnValueand.callThrough

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 angular 工作区配置 `jest-preset-angular` - Configure `jest-preset-angular` with angular workspace 运行jest-preset-angleular时ENONET错误 - ENONET error while running jest-preset-angular Angular 8 和 jest - 找不到文件:jest-preset-angular/InlineHtmlStripStylesTransformer.js - Angular 8 and jest - File not found: jest-preset-angular/InlineHtmlStripStylesTransformer.js 如何在 jest.config.js 中设置 tsconfig 路径。 Angular 8. 开玩笑预设角度 - How to setup tsconfig paths in jest.config.js. Angular 8. jest-preset-angular Angular 4 + Jest-Preset-Angular:使用从文件导入的触发器在主机上测试动画 - Angular 4 + Jest-Preset-Angular : testing animation on host with trigger imported from file 模块<rootDir>未找到转换选项中的 /node_modules/jest-preset-angular/preprocessor.js - Module <rootDir>/node_modules/jest-preset-angular/preprocessor.js in the transform option was not found 角度单元测试组件对SpyObject服务的调用 - Angular Unit Test Component Callthrough On SpyObject of Service 茉莉花:承诺返回的callThrough失败(Jasmine 2.x&Angular.io) - Jasmine: callThrough with Promise return fails (Jasmine 2.x & Angular.io) 使用 IntelliJ 在 NX Workspace 中运行 Jest 测试时出现“错误:未找到预设 jest.preset.js” - "Error: Preset jest.preset.js not found" when using IntelliJ to run Jest tests in NX Workspace 无法预设具有“选定”值的选择-角度引导 - Unable to preset select with 'selected' value - Angular bootstrap
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM