Skip to content

Commit

Permalink
docs: added more docs on how methods no longer mock fetch by default
Browse files Browse the repository at this point in the history
  • Loading branch information
wheresrhys committed Dec 3, 2024
1 parent 2785fb7 commit 3355b66
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/docs/API/more-routing-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ sidebar_label: More routing methods

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()`.

> Note that in older versions of fetch-mock these methods woudl also replace 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).
## .catch()

`.catch(response)`
Expand Down
4 changes: 4 additions & 0 deletions docs/docs/Usage/upgrade-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ Previously this was true in browsers, but in node.js the node-fetch library was

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

### Routing convenience methods no longer mock `fetch`

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.

### Reset methods changed

`.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()`.
Expand Down

0 comments on commit 3355b66

Please sign in to comment.