Skip to content

Commit

Permalink
Merge pull request #851 from wheresrhys/rhys/url-polyfill
Browse files Browse the repository at this point in the history
docs: document use of URL polyfill with react-native
  • Loading branch information
wheresrhys authored Oct 25, 2024
2 parents bcfb1b1 + e900335 commit df91c9c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 7 additions & 0 deletions docs/docs/Usage/requirements.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,10 @@ fetch-mock requires the following to run:
For usage in older versions of Node.js or older browsers consider [using an older version of fetch-mock](/fetch-mock/docs/legacy-api).

If using node-fetch in your application fetch-mock@12 and above may work for you, but the fetch-mock test suite does not run against node-fetch, so it may be safer to use an [older version of fetch-mock](http://localhost:3000/fetch-mock/docs/legacy-api/) that is tested against node-fetch and is less likely to introduce breaking changes.

## Usage with react-native

As react-native ships with a non-spec-compliant version of the URL and URLSearchParams classes, fetch-mock will not run in a react-native environment unless you also include [react-native-url-polyfill](https://www.npmjs.com/package/react-native-url-polyfill). You can either:

1. Include it in your application code. This will add approx 11kb of gzipped code to your bundle.
2. Include it in your test files only. If doing this, its recommended that you have some integration tests that _don't_ use fetch-mock in order to avoid inserting behaviour into your application that relies on the polyfill.
4 changes: 3 additions & 1 deletion docs/docs/Usage/upgrade-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ The filtering behaviour has been rewritten around named routes, and methods retu

## Some convenience routing methods removed

`getOnce()` and `getAnyOnce()`. have all been removed, but the behaviour can still be implemented by the user as follows:
`getOnce()` and `getAnyOnce()` have been removed, but the behaviour can still be implemented by the user as follows:

- `getOnce()` -> `get(url, response, {repeat: 1})`
- `getAnyOnce()` -> `get('*', response, {repeat: 1})`

The same is true for `postOnce()`, `deleteOnce()` etc.

## Options removed

- `overwriteRoutes` - this reflects that multiple routes using the same underlying matcher but different options no longer throw an error.
Expand Down

0 comments on commit df91c9c

Please sign in to comment.