@testing-library/vue: mounting components
Mount Vue components with @testing-library/vue, provide props and global plugins, simulate user events, and assert on the rendered template.
Testing Library for Vue
@testing-library/vue provides the same user-centric testing approach for Vue 3 components. The API mirrors the React version: render(), screen queries, userEvent, and jest-dom matchers.
Installing
Install the testing library packages for Vue.
npm install -D @testing-library/vue @testing-library/user-event @testing-library/jest-dom
# Also install vitest for a Vite project:
npm install -D vitest jsdomAll lessons in this course
- Jest Setup and Basic Tests
- @testing-library/react: render userEvent
- @testing-library/vue: mounting components
- Mocking Modules and API Calls