Installation and use of Vitest
Vitest (https://vitest.dev/) is a test suite, meaning that it provides, out of the box, a set of tools and a framework to perform tests in our code. Being developed by the Vue and Vite teams, it integrates seamlessly with Vite, even sharing the same configuration and respecting each other’s organization. Vitest can be selected during the original creation of a Vue project by selecting the proper option during the creation wizard – a task that will add a /src/__tests__
folder, some examples, and a few extra entries in our package.json
file. But all this boilerplate can be a bit confusing unless we have previous experience in this area. Instead, we start from an already created project, so we will install Vitest as a development dependency – a task that will give us an insight into how it works and is organized.
Install Vitest from the command line at the root directory of the project with this command:
$ npm install -D vitest...