Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5375780

Browse filesBrowse files
authored
feat(coverage): default to text reporter skipFull if agent detected (#10018)
1 parent a1b5f0f commit 5375780
Copy full SHA for 5375780

3 files changed

+24Lines changed: 24 additions & 0 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎docs/config/coverage.md‎

Copy file name to clipboardExpand all lines: docs/config/coverage.md
+4Lines changed: 4 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ You can also pass custom coverage reporters. See [Guide - Custom Coverage Report
133133

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

136+
::: tip AI coding agents
137+
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.
138+
:::
139+
136140
## coverage.reportOnFailure {#coverage-reportonfailure}
137141

138142
- **Type:** `boolean`
Collapse file

‎docs/guide/coverage.md‎

Copy file name to clipboardExpand all lines: docs/guide/coverage.md
+9Lines changed: 9 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -508,3 +508,12 @@ This is integrated with builtin coverage reporters with HTML output (`html`, `ht
508508

509509
<img alt="html coverage in Vitest UI" img-light src="/ui-coverage-1-light.png">
510510
<img alt="html coverage in Vitest UI" img-dark src="/ui-coverage-1-dark.png">
511+
512+
## Coverage in Agent Environments
513+
514+
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:
515+
516+
- `skipFull: true` is set on the `text` reporter, so files with 100% coverage are omitted from the terminal output.
517+
- 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.
518+
519+
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.
Collapse file

‎packages/vitest/src/node/config/resolveConfig.ts‎

Copy file name to clipboardExpand all lines: packages/vitest/src/node/config/resolveConfig.ts
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,17 @@ export function resolveConfig(
427427
}
428428

429429
resolved.coverage.reporter = resolveCoverageReporters(resolved.coverage.reporter)
430+
if (isAgent) {
431+
// default to `skipFull` and add `text-summary` reporter when `text` reporter is used on agents
432+
const text = resolved.coverage.reporter.find(([name]) => name === 'text')
433+
const textSummary = resolved.coverage.reporter.find(([name]) => name === 'text-summary')
434+
if (text) {
435+
(text as any)[1] = { skipFull: true, ...text[1] as any }
436+
if (!textSummary) {
437+
resolved.coverage.reporter.push(['text-summary', {}])
438+
}
439+
}
440+
}
430441
if (resolved.coverage.changed === undefined && resolved.changed !== undefined) {
431442
resolved.coverage.changed = resolved.changed
432443
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.