jest-testdouble
v2.1.0
Published
Additional Jest matchers for testdouble
Downloads
4,700
Maintainers
Readme
Additional Jest matchers for TestDouble
Installation
npm i jest-testdouble expect --save-dev # "expect" is a peer dependency required for jest-testdouble to workor
yarn add jest-testdouble expect --dev # "expect" is a peer dependency required for jest-testdouble to workConfiguration
From Jest test helper (we recommend to use setupTestFrameworkScriptFile)
const td = require('testdouble');
const jestTestDouble = require('jest-testdouble');
jestTestDouble(td);Usage
This package add Jest matchers for TestDouble.
Matchers
- [not].toHaveBeenCalled (alias [not].toBeCalled)
- [not].toHaveBeenCalledWith (alias [not].toBeCalledWith)
- [not].toHaveBeenCalledTimes (alias [not].toBeCalledTimes)
- [not].toHaveBeenLastCalledWith (alias [not].lastCalledWith)
- [not].toHaveBeenNthCalledWith (alias [not].nthCalledWith)
Example
const drink = td.func('drink');
drink('beer');
expect(drink).toHaveBeenCalledWith('beer');Cannot find module 'expect/build/spyMatchers' from 'index.js' error
jest-testdouble requires the expect package to work. You just need to install it
npm i expect --save-devor
yarn add expect --dev