3
3
![ Node.js CI] ( https://github.com/IanVS/vitest-fetch-mock/workflows/Node.js%20CI/badge.svg )
4
4
5
5
This project was forked from [ jest-fetch-mock] ( https://github.com/jefflau/jest-fetch-mock ) , and tweaked slightly to run
6
- with vitest instead of jest . It is mostly compatible with ` jest-fetch-mock ` , with the main difference being that you
6
+ with Vitest instead of Jest . It is mostly compatible with ` jest-fetch-mock ` , with the main difference being that you
7
7
need to create fetchMock with a function call, and provide ` vi ` to it, rather than relying on a global ` vi ` or (` jest `
8
8
in jest-fetch-mock's case). See [ Usage] ( #usage ) for more details.
9
9
10
- Fetch is the canonical way to do HTTP requests in the browser, and it can be used in other environments such as React
11
- Native. Vitest Fetch Mock allows you to easily mock your ` fetch ` calls and return the response you need to fake the HTTP
12
- requests. It's easy to setup and you don't need a library like ` nock ` to get going and it uses Vitest's built-in support
13
- for mocking under the surface. This means that any of the ` vi.fn() ` methods are also available. For more information on
14
- the vitest mock API, check their docs [ here] ( https://vitest.dev/guide/mocking.html )
10
+ Fetch is the canonical way to do HTTP requests in the browser and other modern runtimes. Vitest Fetch Mock allows you to
11
+ easily mock your ` fetch ` calls and return the response you need to fake the HTTP requests. It's easy to setup and you
12
+ don't need a library like ` nock ` to get going and it uses Vitest's built-in support for mocking under the surface. This
13
+ means that any of the ` vi.fn() ` methods are also available. For more information on the Vitest mock API, check their
14
+ docs [ here] ( https://vitest.dev/guide/mocking.html )
15
15
16
- As of version 0.4.0, ` vitest-fetch-mock ` mocks the global [ Fetch] ( https://developer.mozilla.org/en-US/docs/Web/API/Window/fetch ) method,
17
- which should be present in all modern runtimes and browsers.
16
+ As of version 0.4.0, ` vitest-fetch-mock ` mocks the global
17
+ [ Fetch] ( https://developer.mozilla.org/en-US/docs/Web/API/Window/fetch ) method, which is present in all modern runtimes
18
+ and browsers. Previous versions used a fetch polyfill to run in older versions of Node.js. See
19
+ [ Compatibility] ( #compatibility ) for details.
18
20
19
21
## Contents
20
22
@@ -38,8 +40,8 @@ which should be present in all modern runtimes and browsers.
38
40
39
41
### Compatibility
40
42
41
- The most recent version of vitest-fetch-mock supports vitest 2. If you are using vitest version 1.x, please install
42
- vitest-fetch-mock0.2.2.
43
+ The most recent versions of vitest-fetch-mock support Vitest 2 and Node.js 18 and above. If you are using Vitest version
44
+ 1.x or an older version of node, please install ` vitest-fetch-mock0.2.2 ` .
43
45
44
46
### Package Installation
45
47
0 commit comments