Vitest
Installation
npm i -D vitest
More at Adding Vitest to your Project (vitest.dev).
Usage
vitest <command> [options]
# Use with npx
npx vitest [option]
# Use with npm scripts
npm run test
npm run coverage
// package.json e.g.:
{
"scripts": {
"test": "vitest",
"coverage": "vitest run --coverage"
}
}
Commands:
- No command (automatic
watchin development) run(single run with nowatch)watch(same as callingvitestwith no following command, fallbacks torunin CI)dev(alias forwatch)
Options :
-c,--config <config-file>(vite.config.tsby default)--api <boolean>(falseby default)--api.host--api.port <port-number>(51204by default)--api.strictPort--coverage--silent
More at Command Line Interface.
Configuration
// vite.config.json e.g.:
import { defineConfig } from 'vitest/config';
export default defineConfig({
test: {
// ...
}
});
More at Configuring Vitest.