From 9f4dac61acbf78f803c76aedb32b1f9e9ce1110d Mon Sep 17 00:00:00 2001 From: Rhys Evans Date: Fri, 25 Oct 2024 14:27:24 +0100 Subject: [PATCH 1/2] docs: document use of URL polyfill with react-native --- docs/docs/Usage/requirements.md | 7 +++++++ docs/docs/Usage/upgrade-guide.md | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/docs/Usage/requirements.md b/docs/docs/Usage/requirements.md index f826c814..c59e733a 100644 --- a/docs/docs/Usage/requirements.md +++ b/docs/docs/Usage/requirements.md @@ -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 somne integration tests that _don't_ use fetch-mock in order to avoid inserting behaviour into your application that relies on the polyfill. diff --git a/docs/docs/Usage/upgrade-guide.md b/docs/docs/Usage/upgrade-guide.md index b2e6e284..e1507cff 100644 --- a/docs/docs/Usage/upgrade-guide.md +++ b/docs/docs/Usage/upgrade-guide.md @@ -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. From e9003356ba6dcf90706d437b15a8b96a3410b091 Mon Sep 17 00:00:00 2001 From: Rhys Evans Date: Fri, 25 Oct 2024 14:36:15 +0100 Subject: [PATCH 2/2] Update requirements.md --- docs/docs/Usage/requirements.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/docs/Usage/requirements.md b/docs/docs/Usage/requirements.md index c59e733a..59d5b963 100644 --- a/docs/docs/Usage/requirements.md +++ b/docs/docs/Usage/requirements.md @@ -20,4 +20,4 @@ If using node-fetch in your application fetch-mock@12 and above may work for you 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 somne integration tests that _don't_ use fetch-mock in order to avoid inserting behaviour into your application that relies on the polyfill. +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.