Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/config/coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,10 @@ You can also pass custom coverage reporters. See [Guide - Custom Coverage Report

You can check your coverage report in Vitest UI: check [Vitest UI Coverage](/guide/coverage#vitest-ui) for more details.

::: tip AI coding agents
When Vitest detects it is running inside an AI coding agent, it automatically adds the `text-summary` reporter and sets `skipFull: true` on the `text` reporter to reduce output and minimize token usage.
:::

## coverage.reportOnFailure {#coverage-reportonfailure}

- **Type:** `boolean`
Expand Down
9 changes: 9 additions & 0 deletions docs/guide/coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -508,3 +508,12 @@ This is integrated with builtin coverage reporters with HTML output (`html`, `ht

<img alt="html coverage in Vitest UI" img-light src="/ui-coverage-1-light.png">
<img alt="html coverage in Vitest UI" img-dark src="/ui-coverage-1-dark.png">

## Coverage in Agent Environments

When Vitest detects it is running inside an AI coding agent, it automatically adjusts the default `text` reporter to reduce output and minimize token usage:

- `skipFull: true` is set on the `text` reporter, so files with 100% coverage are omitted from the terminal output.
- The [`text-summary`](/config/coverage#coverage-reporter) reporter is added automatically, so the agent always sees a concise totals table even when `skipFull` hides all individual files.

These adjustments only apply when the `text` reporter is already part of the active reporter list (it is included in the default). Explicitly configured reporters are never removed.
11 changes: 11 additions & 0 deletions packages/vitest/src/node/config/resolveConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,17 @@ export function resolveConfig(
}

resolved.coverage.reporter = resolveCoverageReporters(resolved.coverage.reporter)
if (isAgent) {
// default to `skipFull` and add `text-summary` reporter when `text` reporter is used on agents
const text = resolved.coverage.reporter.find(([name]) => name === 'text')
const textSummary = resolved.coverage.reporter.find(([name]) => name === 'text-summary')
if (text) {
(text as any)[1] = { skipFull: true, ...text[1] as any }
if (!textSummary) {
resolved.coverage.reporter.push(['text-summary', {}])
}
}
}
if (resolved.coverage.changed === undefined && resolved.changed !== undefined) {
resolved.coverage.changed = resolved.changed
}
Expand Down
Loading