@testing-library/react: render userEvent
Render components in a simulated DOM, query by role and label text, fire user interactions with userEvent, and assert on visible output.
Testing Library Philosophy
@testing-library encourages tests that resemble how users interact with the UI. Query by role, label, and text — not by implementation details like CSS class names or component internals.
Installing Testing Library
Install Testing Library for React and the userEvent package for user interaction simulation.
npm install -D @testing-library/react @testing-library/user-event @testing-library/jest-domAll lessons in this course
- Jest Setup and Basic Tests
- @testing-library/react: render userEvent
- @testing-library/vue: mounting components
- Mocking Modules and API Calls