chai-jest-mocks
Chai plugin that adds assertions for jest mock functions
NOTE this is still very much a work in progress, more matchers and better documentation (and tests) are coming!
Installation
On the command line:
$ npm install --save-dev chai-jest-mocks
Usage
First, tell chai
that you want to use chai-jest-mocks
const chai = ;const chaiJestMock = ; chai;
Then you will have access to the new assertions:
// Expect a mock to be calledtohave; // Expect a mock to have been called a certain number of timestohave; // Expect a mock to have been called with specific argumentstohave; // Expect a mock to have been last called with specific argumentstohave; // Expect a mock to have been nth (in this case, second) called with specific argumentstohave; // Expect a mock to have returned succesfully (i.e, not throw)tohave; // Expect a mock to have returned succesfully a certain number of timestohave;