[Jest] Using Jest toHaveBeenCalledWith for testing primitive data types and partial objects

Example:

    expect(contextSpy.sendEncodedMessage).toHaveBeenCalledWith(
      expect.objectContaining({
        correlationId: expect.objectContaining({ operationId: 'open' }),
        subtype: 'open',
        type: 'navigation',
      }),
      navigationMsg.TYPE,
      navigationMsg.SUBTYPE.OPEN,
    )

 

More: https://geshan.com.np/blog/2022/07/jest-tohavebeencalledwith/

posted @   Zhentiw  阅读(20)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
历史上的今天:
2021-11-03 [CSS] z-index
2021-11-03 [Javascript] Safely Access a Property on a JavaScript Array with Optional Chaining
2020-11-03 [Javascript] Broadcaster + Operator + Listener pattern -- 13. Repeat When Done with a Repeat Operator
2020-11-03 [Javascript] Broadcaster + Operator + Listener pattern -- 12. Repeat a broadcaster that is DONE
2017-11-03 [Angular] How to get Store state in ngrx Effect
2014-11-03 [Angular-Scaled web] 2. Architecture sub-modules
2014-11-03 [Angular-Scaled web] 1. Architecture and file structure
点击右上角即可分享
微信分享提示