Registry / testing / fetch-mock-forwarder

fetch-mock-forwarder

JSON →
library1.0.0jsnpmunverified

A drop-in replacement for isomorphic-fetch designed to enable fetch-mock usage in browser environments. Version 1.0.0, no release cadence defined. This package re-exports the global fetch by requiring whatwg-fetch, allowing webpack aliasing so that modules importing isomorphic-fetch will use it instead, enabling fetch-mock to intercept requests.

npm install fetch-mock-forwarder
INSTALL
IMPORT
SIG · FETCH-MOCK-FORWARD
F
fetch-mock-forwarder
testingjavascriptv1.0.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

(none)
Use via webpack alias: 'isomorphic-fetch' -> 'fetch-mock-forwarder'
Direct import: import fetch from 'fetch-mock-forwarder' (does not export anything)
The package does not export any symbols; it only loads whatwg-fetch and uses the global fetch.

Shows how to alias isomorphic-fetch to fetch-mock-forwarder in webpack and use it with fetch-mock.

// webpack.config.js module.exports = { resolve: { alias: { 'isomorphic-fetch': 'fetch-mock-forwarder' } } }; // test file import fetchMock from 'fetch-mock'; import 'isomorphic-fetch'; // now uses fetch-mock-forwarder fetchMock.mock('http://example.com', 200); const response = await fetch('http://example.com'); console.assert(response.status === 200);
Debug
Known issues
gotchaRequires webpack alias; does not work without bundler configuration.
fix
Configure webpack resolve.alias for 'isomorphic-fetch' as shown in quickstart.
affects: >=1.0.0
gotchaNo named exports; wrapper only sets up global fetch.
fix
Do not attempt to import any symbol from this package.
affects: >=1.0.0
gotchaAssumes global fetch exists after requiring whatwg-fetch; might conflict with other polyfills.
fix
Ensure whatwg-fetch is not loaded separately to avoid double polyfill.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'isomorphic-fetch'
Alias not set in bundler configuration.
fix
Add resolve.alias in webpack.config.js: 'isomorphic-fetch': 'fetch-mock-forwarder'
fetch is not defined
fetch-mock-forwarder not loaded (alias not working) or whatwg-fetch not bundled correctly.
fix
Verify webpack alias and that whatwg-fetch is installed.
Upgrade
Version history
1.0.0latest on npm
Audit
Dependencies
whatwg-fetchrequiredprovides the global fetch polyfill
Agent activity
2 hits · last 30 days
node
2
Resources
fetch-mock-forwarder — npm install fetch-mock-forwarder · libregistry