[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 @ 2022-11-03 17:57  Zhentiw  阅读(20)  评论(0编辑  收藏  举报