React Testing Library + Vitest/Jest Setup
Install and configure Vitest/Jest with React Testing Library; use jsdom, render components, and query the DOM like a user.
Why this stack
Goal: Test components like a user interacts.
- Vitest/Jest runner
- jsdom environment
- React Testing Library (RTL)
Install + env
Install:
- npm i -D vitest @testing-library/react @testing-library/user-event jsdom
- Set test env to jsdom
- Add scripts: test, test:watch
All lessons in this course
- React Testing Library + Vitest/Jest Setup
- Queries, Events, Assertions — Forms & Async UI
- Mocking Fetch & Timers