2.1.0 • Published 2 years ago
jest-testdouble v2.1.0
Additional Jest matchers for TestDouble
Installation
npm i jest-testdouble expect --save-dev # "expect" is a peer dependency required for jest-testdouble to work
or
yarn add jest-testdouble expect --dev # "expect" is a peer dependency required for jest-testdouble to work
Configuration
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-dev
or
yarn add expect --dev