Installation
shell
npm install --save-dev @vue/test-utilsshell
yarn add --dev @vue/test-utilsUsage
Vue Test Utils is framework agnostic - you can use it with whichever test runner you like.
Vitest (Recommended)
Vitest is the recommended test runner for Vue projects. It is built on Vite, supports .vue files out of the box, and provides a fast, modern testing experience with native ESM support.
shell
npm install --save-dev vitestNo additional transform configuration is needed when using Vitest with a Vite-based project. See the Vitest getting started guide for more details.
Jest
You can also use Jest with Vue Test Utils. To load .vue files with Jest, you will need vue-jest. You can install it with vue-jest@next and configure it with Jest's transform option.
Continue reading to learn more about Vue Test Utils.