A browser library that intercepts AJAX calls to mock a REST server based on JSON data. Version 4.2.1 includes TypeScript types and supports MSW, fetch-mock, and Sinon for interception. It enables client-side testing of SPA REST clients without a live server by patching XMLHttpRequest or fetch. Differentiators include out-of-box support for multiple mocking libraries, automatic CRUD routes from a simple data object (resources with records), and compatibility with react-admin. Release cadence is stable with periodic updates.
npm install fakerestNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates an MSW handler that intercepts all fetch requests to localhost:3000 and returns REST-like responses based on provided JSON data.
Ensure each resource is an array of objects (for list) or a single object (for singleton).
Add custom handlers via MSW/fetch-mock/Sinon for non-REST routes.
Use http.all(/\/api\//, handler) instead of http.all('*/api/*', handler).Ensure all resource items have an 'id' property (or configure idAttribute in options).
Run `npx msw init public` (or your public dir) to generate the mockServiceWorker.js file.
Wrap singleton data in an array or use a singleton resource pattern (see docs).
No dependency data recorded yet.