jest-testdouble

2.1.0 • Public • Published

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

Dependencies (0)

    Dev Dependencies (6)

    Package Sidebar

    Install

    npm i jest-testdouble

    Weekly Downloads

    109

    Version

    2.1.0

    License

    MIT

    Unpacked Size

    9.88 kB

    Total Files

    5

    Last publish

    Collaborators

    • lytc