Overview
This product is a testing library for Vue components, known as Vue Testing Library. It is specifically designed to facilitate writing tests that closely resemble how Vue components are used in actual applications. The library is built with guiding principles focused on simplicity, flexibility, and encouraging testing practices that align with Vue component usage. Vue Testing Library supports Vue 2 and Vue 3, along with dependencies like jest-dom.
Features
- Coverage Status: Check the coverage status of your tests.
- npm version: Install the library as one of your project’s devDependencies using npm.
- Documentation: Read and edit the comprehensive documentation.
- Installation: Quick and easy installation guide for npm users.
- Guiding Principles: Principles focused on writing tests resembling software usage.
- Typings: TypeScript 4.X support with type definitions in the types directory.
- ESLint support: Lint test files using the official eslint-plugin.
- Contributors: List of contributors who have contributed to the project.
Installation
To install Vue Testing Library as a devDependency in your project, use npm:
npm install @testing-library/vue
To install dependencies for Vue 3 and @vue/compiler-sfc, include peerDependencies:
npm install vue@3 @vue/compiler-sfc
For Vue 2 users, install version 5 of the library:
npm install @testing-library/vue@5
To add jest-dom for custom matchers, consider installing:
npm install @testing-library/jest-dom
Summary
Vue Testing Library is a versatile tool for testing Vue components, encouraging practices that mirror real-world usage scenarios. With support for Vue 2 and Vue 3, along with peer dependencies, eslint support, and TypeScript compatibility, it aims to simplify and enhance the testing experience for Vue developers. The library’s guiding principles, detailed documentation, and active community of contributors make it a valuable asset for testing Vue applications efficiently and effectively.