Skip to content

Commit 97160c4

Browse files
authored
Merge pull request #889 from wheresrhys/rhys/issue-888
docs: added more docs on how methods no longer mock fetch by default
2 parents 2785fb7 + 872beab commit 97160c4

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

docs/docs/API/more-routing-methods.md

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ sidebar_label: More routing methods
77

88
These methods allow defining routes for common use cases while avoiding writing hard to read configuration objects. They all return the fetchMock instance, and are therefor chainable. Unless noted otherwise, each of the methods below have the same signature as `.route()`.
99

10+
> Note that in older versions of fetch-mock these methods also replaced global `fetch` with your mock. From version 12 onwards this is no longer the case, and you will need to start your tests with `fetchMock.mockGlobal()` or similar. [Read the mocking and spying docs](/fetch-mock/docs/API/mocking-and-spying).
11+
1012
## .catch()
1113

1214
`.catch(response)`

docs/docs/Usage/upgrade-guide.md

+4
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ Previously this was true in browsers, but in node.js the node-fetch library was
1616

1717
This combined adding a route with mocking the global instance of `fetch`. These are now split into 2 methods: `.route()` and `.mockGlobal()`.
1818

19+
### Routing convenience methods no longer mock `fetch`
20+
21+
Similar to the last point, `.once()`, `.get()`, `.post()`, `getOnce()`, `postOnce()` and all other routing convenience methods no longer mock the global instance of `fetch`, and you will need to call `.mockGlobal()` explicitly.
22+
1923
### Reset methods changed
2024

2125
`.reset()`, `.restore()`, `.resetBehavior()` and `.resetHistory()` have been removed and replaced with [methods that are more granular and clearly named](/fetch-mock/docs/API/resetting). Note that the [jest](/fetch-mock/docs/wrappers/jest) and [vitest](/fetch-mock/docs/wrappers/vitest) wrappers for fetch-mock still implement `.mockClear()`, `mockReset()` and `mockRestore()`.

0 commit comments

Comments
 (0)