2.1.0 • Published 2 years ago

jest-testdouble v2.1.0

Weekly downloads
5
License
MIT
Repository
github
Last release
2 years ago

Additional Jest matchers for TestDouble

Build Status npmjs

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
2.1.0

2 years ago

2.0.0

5 years ago

1.0.1

6 years ago

1.0.0

6 years ago