How to check multiple arguments on multiple calls for jest spies? How to check multiple arguments on multiple calls for jest spies? typescript typescript

How to check multiple arguments on multiple calls for jest spies?


I was able mock multiple calls and check the arguments this way:

expect(mockFn.mock.calls).toEqual([  [arg1, arg2, ...], // First call  [arg1, arg2, ...]  // Second call]);

where mockFn is your mocked function name.


The signature is .toHaveBeenCalledWith(arg1, arg2, ...), where arg1, arg2, ... means in a single call (see).

If you want to test multiple calls, just expect it multiple times.

Unfortunately, I have not yet found a method to test the order of multiple calls.