jest-callslike
v0.2.1
Published
A jest assertion that checks calls for count, order and informed parameters, all at once
Downloads
2,271
Readme
A jest assertion that checks calls for count, order and informed parameters, all at once.
How to install
npm i jest-callslike
How to use it
Import this module in your test
import 'jest-callslike';
Then, just use the assertion informing each group of arguments as an array
expect(spy).toHaveCallsLike(
['a', 1, false],
['b', 2, true],
);
If you want to check if the function was never called, use the assertion with no arguments:
expect(spy).toHaveCallsLike();
jest-callslike also adds a new custom matcher expect.exact. This matcher only passes when the value compared to it is exact the same used, ie, the same reference:
expect(spy).toHaveCallsLike(expect.exact(myObject));
License
Licensed under MIT.