How can I get the arguments called in jest mock function?

前端 未结 3 787
陌清茗
陌清茗 2021-02-02 04:50

How can I get the arguments called in jest mock function?

I want to inspect the object that is passed as argument.

3条回答
  •  北海茫月
    2021-02-02 05:29

    I prefer lastCalledWith() over toHaveBeenCalledWith(). They are both the same but the former is shorter and help me reduce the cognitive load when reading code.

    expect(mockedFn).lastCalledWith('arg1', 'arg2')
    

提交回复
热议问题