Vitest is a Vite-powered test runner that watches by default
Answer: Vitest is a testing framework powered by Vite. Install Vitest with npm install -D vitest. By default, tests must contain .test. or .spec. in their file name. Add a package.json script of "test": "vitest" and run it. A bare vitest run watches for file changes; use vitest run to execute once.
Config and scripts
Vitest reads your existing vite.config. by default, so Vite plugins already in that file apply to tests. You can also add a dedicated vitest.config.. Vitest requires Vite >=v6.4.0 and Node >=v22.12.0. A typical package.json script is "test": "vitest". Tests import expect and test from vitest.
The CLI in source
createCLI calls cac('vitest'), then cli.version(version), and addCliOptions.
See also
Claims
- id: C1 claim: Vitest is a testing framework powered by Vite. source: S1 evidence: "is a next generation testing framework"
- id: C2 claim: By default, test file names must contain .test. or .spec. source: S1 evidence: "tests must contain
.test.or.spec.in their file name."
- id: C3 claim: vitest run executes tests once without watching for file changes. source: S1 evidence: "To run tests once without watching for file changes, use
vitest run."
- id: C4 claim: The Vitest CLI is created with cac under the name vitest. source: S2 evidence: "const cli = cac('vitest')"
- id: C5 claim: createCLI is the function that builds that CLI. source: S2 evidence: "export function createCLI(options: CliParseOptions = {}): CAC {"
Sources
- [S1] Getting Started. Vitest docs. https://vitest.dev/guide/ . License: MIT. Accessed 2026-11-11.
- [S2] Vitest createCLI. Vitest source. https://github.com/vitest-dev/vitest/blob/main/packages/vitest/src/node/cli/cac.ts . License: MIT. Accessed 2026-11-11.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources and notices: Vitest documentation and source (vitest-dev/vitest): Copyright (c) 2021-Present VoidZero Inc. and Vitest contributors; MIT (https://raw.githubusercontent.com/vitest-dev/vitest/main/LICENSE). Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Vitest docs and Vitest source (vitest-dev/vitest), MIT. Notices: Vitest documentation and source (vitest-dev/vitest): Copyright (c) 2021-Present VoidZero Inc. and Vitest contributors; MIT (https://raw.githubusercontent.com/vitest-dev/vitest/main/LICENSE).
Cite this
iinventedlight. 2026. "Vitest is a Vite-powered test runner that watches by default." iinventedlight Library, iil:note:y3yh2s6w, version of 2026-11-11. https://iinventedlight.com/library/notes/vitest-test-runner/. License: CC-BY-4.0.
@misc{iil_note_y3yh2s6w,
author = {{iinventedlight}},
title = {{Vitest is a Vite-powered test runner that watches by default}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-11},
url = {https://iinventedlight.com/library/notes/vitest-test-runner/},
note = {Permanent ID iil:note:y3yh2s6w. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/vitest-test-runner.md.