This project demonstrates how you can make a reusable custom render function for testing components that rely on React's Context, with the flexibility of using default context, or the specified context in an individual test senario.
Link to my Medium article: https://medium.com/@janesfrontenddiary/a-reusable-way-to-test-react-components-that-make-use-of-react-context-a82150344c46
You can find the custom render function here.
You can find an example using React's Context here.
You can find an example using react-router-dom here.
You can find an example using React Query here.
- React(v18) + Vite
- Typescript
- Tailwind CSS
- Vitest + React Testing Library
- Eslint
- Prettier, Prettier Tailwind plugin
This project is built using Vite and can be run using the following scripts:
git clone https://github.com/d3v-g/medium-custom-render
npm install
npm run dev
npm run test
npm run lint
npm run format
npm run build
npm run preview