Thresholds & Ignoring Code in Vitest

From the Vitest cheat sheet ยท Coverage ยท verified Nov 2026

Thresholds & Ignoring Code

Fail the run when coverage drops and exclude code from the report

typescript
coverage: {
  thresholds: {
    lines: 80,
    functions: 80,
    branches: 75,
    statements: 80,
  },
}

/* v8 ignore next -- @preserve */
if (process.env.DEBUG) console.log(state)
๐Ÿ“Œ The run fails when coverage drops below a threshold
โš ๏ธ Add -- @preserve or the transpiler can strip the ignore comment
๐Ÿ’ก autoUpdate rewrites your config with the new, higher thresholds
๐Ÿ” v5: glob thresholds no longer inherit the top-level perFile
coveragethresholdsignore

Continue with Vitest

Save the full cheat sheet or work through every related task.

More Vitest tasks

Back to the full Vitest cheat sheet