This repository showcases a Mock Service Worker (MSW) v2 setup in a React environment, seamlessly integrated with Jest and React Testing Library. The configuration allows MSW to intercept API calls during development and unit testing, offering comprehensive control and flexibility throughout the development process.
- Detailed article providing a step-by-step explanation of the implementation process.
- Configuration of handlers, setupWorker, and setupServer for API mocking.
- On-demand API interception during development using MSW's browser integration.
- API interception in Jest and React Testing Library environments using MSW's Node.js integration.
- Mock Service Worker (MSW) for API mocking
- Jest for unit testing
- React Testing Library for component testing
- React for building the UI
- Clone the repository
- Install dependencies:
npm install - Run the mock API:
npm run dev:mock - Start the development server:
npm run dev
To run all tests, use the following command: npm run test