Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@fetch-mock/jest

wheresrhys98.7kMIT0.2.15TypeScript support: included

jest wrapper for fetch-mock

fetch, http, mock, testing, spy, stub, jest

readme

@fetch-mock/jest

A wrapper for fetch-mock that improves the developer experience when working with jest. It provides the following:

  • Adds methods to fetchMock which wrap its default methods, but align more closely with jest's naming conventions.
  • Extends expect with convenience methods allowing for expressive tests such as expect(fetchMock).toHavePosted('http://example.com', {id: 'test-id'}).
  • Can optionally be hooked in to jest's global mock management methods such as clearAllMocks().

Requirements

@fetch-mock/jest requires either of the following to run:

  • jest
  • The fetch API, via one of the following:
    • Node.js 18+ for full feature operation
    • Any modern browser that supports the fetch API
    • node-fetch when testing in earlier versions of Node.js (this is untested, but should mostly work)

Documentation and Usage

See the project website

License

@fetch-mock/vitest is licensed under the MIT license. Copyright © 2024, Rhys Evans

changelog

Changelog

0.2.15 (2025-03-03)

Dependencies

  • The following workspace dependencies were updated
    • dependencies
      • fetch-mock bumped from ^12.5.1 to ^12.5.2

0.2.14 (2025-03-01)

Dependencies

  • The following workspace dependencies were updated
    • dependencies
      • fetch-mock bumped from ^12.5.0 to ^12.5.1

0.2.13 (2025-03-01)

Dependencies

  • The following workspace dependencies were updated
    • dependencies
      • fetch-mock bumped from ^12.4.0 to ^12.5.0

0.2.12 (2025-02-23)

Dependencies

  • The following workspace dependencies were updated
    • dependencies
      • fetch-mock bumped from ^12.3.0 to ^12.4.0

0.2.11 (2025-02-23)

Documentation Changes

  • document patch for comptibility with jsdom (a2f6094)

0.2.10 (2025-02-04)

Dependencies

  • The following workspace dependencies were updated
    • dependencies
      • fetch-mock bumped from ^12.2.1 to ^12.3.0

0.2.9 (2025-01-28)

Bug Fixes

  • force release of @fetch-mock/jest (7ff5915)

Dependencies

  • The following workspace dependencies were updated
    • dependencies
      • fetch-mock bumped from ^12.2.0 to ^12.2.1

0.2.8 (2025-01-11)

Bug Fixes

  • incorrect Jest extension TypeScript type (9d47c33)

0.2.7 (2024-11-29)

Bug Fixes

  • add not type definitions (68b24e7)
  • adding jestMock extension support to match documentation (9e41a81)
  • adding types to jest matchers (033048a)

0.2.6 (2024-11-15)

Bug Fixes

  • remove extraneous console.log (c2c92a4)

Dependencies

  • The following workspace dependencies were updated
    • dependencies
      • fetch-mock bumped from ^12.1.0 to ^12.2.0

0.2.5 (2024-11-08)

Dependencies

  • The following workspace dependencies were updated
    • dependencies
      • fetch-mock bumped from ^12.0.3 to ^12.1.0

0.2.4 (2024-11-08)

Dependencies

  • The following workspace dependencies were updated
    • dependencies
      • fetch-mock bumped from 12.0.2 to 12.0.3

0.2.3 (2024-10-30)

Bug Fixes

  • use file extension to avoid import errors for vitest and jest wrappers (f1f25f1)

0.2.2 (2024-10-28)

Dependencies

  • The following workspace dependencies were updated
    • dependencies
      • fetch-mock bumped from 12.0.1 to 12.0.2

0.2.1 (2024-10-27)

Dependencies

  • The following workspace dependencies were updated
    • dependencies
      • fetch-mock bumped from 12.0.0 to 12.0.1

0.2.0 (2024-10-24)

⚠ BREAKING CHANGES

  • Replaced legacy fetch-mock code with fetch-mock/core code

Features

  • Replaced legacy fetch-mock code with fetch-mock/core code (999ce92)

Documentation Changes

  • bring jest docs into website (18ae8b6)

Dependencies

  • The following workspace dependencies were updated
    • dependencies
      • fetch-mock bumped from 11.1.5 to 12.0.0

0.1.1 (2024-09-25)

Bug Fixes

  • change export order so default is last (bc9c41d)

Dependencies

  • The following workspace dependencies were updated
    • dependencies
      • @fetch-mock/core bumped from ^0.7.0 to ^0.7.1

0.1.0 (2024-08-31)

Features

  • new @fetch-mock/jest wrapper (93f35c6)
  • start implementing jest and vitest wrappers (804f885)

Bug Fixes

  • hooks into jest's global mock management functions (aaadda0)
  • one step closer to fixing types in jest wrapper (b69f595)