This is a simple project template to demonstrate how to use MSW with React Native. It uses Jest and React Testing Library to test the application.
This application also has @tanstack/react-query to show how to use MSW with react-query for async state management and how I would typically test this in my application, including testing the rendering logic as well as isolating the useQuery
or useMutation
hooks in a test.
- Clone the repository
- Run
yarn install
- Run
yarn start
- Run
yarn android
oryarn ios
- Run
yarn test
- Run
yarn test:cov
to generate a coverage report, example below
Example app demo https://github.com/lewiscasewell/react-native-msw-template/assets/64678409/46512e9b-7c4a-4503-b345-5c81ebfd7727