@bloombug/fetch-mock-jest
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

fetch-mock-jest

This project is bootstrapped with TSDX 🙏.

Installation

yarn add @bloombug/fetch-mock-jest -D

npm install -D fetch-mock-jest

Usage

This library adds the following assertions.

  • expect(fetchMock).toHaveFetched(filter, options)

Note: filter and options are the same as those used by fetch-mock's inspection methods.

Example

import fetchMock from '@bloombug/fetch-mock-jest';
import {render, waitFor} from '@testing-library/react'

describe('<MyComponent />, () => {
  it('renders', () => {
    fetchMock.mock('/foobar');

    render(<MyComponent />);

    await screen.findByRole('heading', {name: 'Title'})

    expect(fetchMock).toHaveFetched('/foobar');
  });
});

Package Sidebar

Install

npm i @bloombug/fetch-mock-jest

Weekly Downloads

1

Version

0.1.1

License

MIT

Unpacked Size

34.4 kB

Total Files

19

Last publish

Collaborators

  • macdonaldr93