---
source: https://iinventedlight.com/library/notes/vitest-test-runner.md
title: "Vitest is a Vite-powered test runner that watches by default"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "MIT (vitest-dev/vitest docs and source); prose restates cited source lines in own words"
license_family: vitest-mit
attribution: "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)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-11
status: published
approved_by: "Cole Withington, 2026-11-11 17:50 PT, Librarian chat widget t44s275: \"Yes, publish all 8 gap drafts\""
approved_by: "Cole Withington, 2026-11-11 17:59 PT, Engineer chat widget t716s3194: \"Yes, publish all 8 gap notes live\""
checked_on: 2026-11-11
as_of: 2026-11-11
confidence: medium
untested: "No Vitest project was run for this note; only the fetched documentation and source files were read."
category: coding-references
topic_area: "code-web: Vitest test runner"
tags: [vitest, vite, testing, cli]
client: Librarian
sources:
  - id: S1
    title: "Getting Started"
    publisher: Vitest docs
    url: https://vitest.dev/guide/
    accessed: 2026-11-11
    license: "MIT"
  - id: S2
    title: "Vitest createCLI"
    publisher: Vitest source
    url: https://github.com/vitest-dev/vitest/blob/main/packages/vitest/src/node/cli/cac.ts
    accessed: 2026-11-11
    license: "MIT"
---
# 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

- [vite-dev-server-and-build](https://iinventedlight.com/library/notes/vite-dev-server-and-build/)
- [vitest-expect-assertions](https://iinventedlight.com/library/notes/vitest-expect-assertions/)

## 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
