Extends Mock.js to support intercepting fetch-based AJAX requests, enabling seamless mocking of fetch API calls alongside existing XMLHttpRequest mocks. Current stable version is 2.0.0, released with a breaking change in import syntax (named export instead of default). Release cadence is low, with only a few versions. Key differentiators: integrates with Mock.js for full mock syntax support, or can be used standalone for simple fetch-only mocking without Mock.js dependency. Important: must be disabled in production to avoid runtime side effects.
npm install mockjs-fetchNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Integrates with Mock.js to mock fetch requests with full mock syntax support including data templates.
Use `import { mockFetch } from 'mockjs-fetch'` instead of `import mockFetch from 'mockjs-fetch'`Always pass Mock as argument: `mockFetch(Mock)`
Wrap mock imports in conditional or use build tools to exclude production builds
Use full integration with Mock.js for template syntax, or write plain static data in standalone mode
import { mockFetch } from 'mockjs-fetch';Ensure mockFetch(Mock) is executed before any fetch calls
import { Mock } from 'mockjs-fetch'; // not import Mock from ...