jest-mocks
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

Jest Mocks

A set of useful mocks and helpers for the Jest unit testing framework.

Available helpers

All provided helpers have full TypeScript support with inferred types based on the arguments they're called with.

filterMockCalls(mock, ...args)

Returns an array of calls from the provided Jest Mock, where args matches the args the mock was called with.

findMockCall(mock, ...args)

Returns the first matching call from the provided Jest Mock, where args matches the args the mock was called with.

resolvedPromise(value)

Returns a Promise that will instantly resolve with the provided value.

rejectedPromise(error)

Returns a Promise that will instantly be rejected with the provided error.

mockWithResolvedPromise(value)

Returns an async Jest Mock that will instantly resolve with the provided value when called.

mockWithRejectedPromise(error)

Returns an async Jest Mock that will instantly be rejected with the provided error when called.

Dependencies (0)

    Dev Dependencies (13)

    Package Sidebar

    Install

    npm i jest-mocks

    Weekly Downloads

    173

    Version

    1.0.5

    License

    ISC

    Unpacked Size

    6.55 kB

    Total Files

    7

    Last publish

    Collaborators

    • voodoocreation