Skip to content

codibre/jest-callslike

Repository files navigation

Actions Status Actions Status Actions Status Test Coverage Maintainability Packages npm version

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.

About

A jest assertion that checks calls for count, order and informed parameters, all at once

Resources

License

Stars

Watchers

Forks

Packages

No packages published