jest-callslike
TypeScript icon, indicating that this package has built-in type declarations

0.2.1 • Public • Published

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.

Package Sidebar

Install

npm i jest-callslike

Weekly Downloads

139

Version

0.2.1

License

MIT

Unpacked Size

8.5 kB

Total Files

6

Last publish

Collaborators

  • pedrosodre
  • danielcarvalho
  • gustavobeavis
  • paulododt
  • fgabrielsilva
  • danielgaleni
  • farenheith
  • jeocoutinho