Skip to content

vitest

Vitest suites: test lint rules, and passing tests before every push. Level all adds a coverage minimum. It requires javascript. Guide: Tests.

A scope has filenames vitest.config.* or vitest.workspace.*, or a dependency on vitest.

Runs Vitest with coverage, and fails on a failed test or when lines, branches, functions, or statements fall under their minimums.

Runs at the push stage, once per scope, and loads your code.

A coverage minimum keeps new code from arriving untested.

Fix each failed test, and add tests for the code that the report marks uncovered. Lower a minimum under coverage only with a reason.

Vitest reports ERROR: Coverage for lines (85%) does not meet global threshold (90%). Add tests for the uncovered lines.

gspot ignore vitest/tests --paths "<path>" --reason "<why>"

To silence one place, write a comment such as:

/* v8 ignore next -- reason: only a full disk reaches this branch */
Setting What it sets
coverage.min_line_percent The minimum percentage of source lines covered by tests.
coverage.min_branch_percent The minimum percentage of source branches covered by tests.
coverage.min_function_percent The minimum percentage of source functions covered by tests.
coverage.min_statement_percent The minimum percentage of source statements covered by tests.
Tool Version
vitest 2.0.0 or later, install it yourself
@vitest/eslint-plugin 1.6.27
@vitest/coverage-v8 Any, install it yourself