A fixture proxy for React Cosmos that enables mocking of fetch API responses during component development and testing. Version 4.8.2 is the latest stable release, part of the react-cosmos-classic line (pre-5.x). This proxy allows developers to define mock fetch responses declaratively in fixtures, avoiding the need for a separate mock server or service worker. It integrates seamlessly with React Cosmos’s fixture system, supporting dynamic responses based on request properties. Lightweight and focused, it differs from more general mocking libraries like MSW by being purpose-built for Cosmos’s fixture-driven workflow. No release cadence information is available.
npm install react-cosmos-fetch-proxyNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to set up FetchProxy in React Cosmos config and define mock fetch responses in fixtures.
Ensure your component uses the native fetch API, or use a polyfill.
Define fetch mocks inside individual fixtures using 'fetch' key.
Use alternative mocking libraries for React Cosmos v5+.
Install and import 'node-fetch' in your Cosmos setup: import 'node-fetch';
Ensure fetch fixture has method property or response object properly defined: { matcher: '...', response: { status: 200, body: {} } }Use import FetchProxy from 'react-cosmos-fetch-proxy' or const FetchProxy = require('react-cosmos-fetch-proxy').default