From 6ff7972e16666361780e3ca076f8f3cdf2c91ad8 Mon Sep 17 00:00:00 2001 From: Vladimir Date: Mon, 20 Apr 2026 09:34:15 +0200 Subject: [PATCH 1/2] fix: alias `agent` reporter to `minimal` (#10157) --- config/reporters.md | 2 +- guide/cli-generated.md | 2 +- guide/reporters.md | 15 +++++++++------ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/config/reporters.md b/config/reporters.md index 6c9b3335..2098d8f6 100644 --- a/config/reporters.md +++ b/config/reporters.md @@ -42,7 +42,7 @@ Note that the [coverage](/guide/coverage) feature uses a different [`coverage.re - [`tap-flat`](/guide/reporters#tap-flat-reporter) - [`hanging-process`](/guide/reporters#hanging-process-reporter) - [`github-actions`](/guide/reporters#github-actions-reporter) -- [`agent`](/guide/reporters#agent-reporter) +- [`minimal`](/guide/reporters#minimal-reporter) (aliased as `agent`) - [`blob`](/guide/reporters#blob-reporter) ## Example diff --git a/guide/cli-generated.md b/guide/cli-generated.md index 63353248..ac54ea5f 100644 --- a/guide/cli-generated.md +++ b/guide/cli-generated.md @@ -102,7 +102,7 @@ Hide logs for skipped tests - **CLI:** `--reporter ` - **Config:** [reporters](/config/reporters) -Specify reporters (default, agent, blob, verbose, dot, json, tap, tap-flat, junit, tree, hanging-process, github-actions) +Specify reporters (default, agent, minimal, blob, verbose, dot, json, tap, tap-flat, junit, tree, hanging-process, github-actions) ### outputFile diff --git a/guide/reporters.md b/guide/reporters.md index 72a86146..34307954 100644 --- a/guide/reporters.md +++ b/guide/reporters.md @@ -99,7 +99,7 @@ This example will write separate JSON and XML reports as well as printing a verb By default (i.e. if no reporter is specified), Vitest will display summary of running tests and their status at the bottom. Once a suite passes, its status will be reported on top of the summary. ::: tip -When Vitest detects it is running inside an AI coding agent, the [`agent`](#agent-reporter) reporter is used instead to reduce output and minimize token usage. You can override this by explicitly configuring the [`reporters`](/config/reporters) option. +When Vitest detects it is running inside an AI coding agent, the [`minimal`](#minimal-reporter) reporter is used instead to reduce output and minimize token usage. You can override this by explicitly configuring the [`reporters`](/config/reporters) option. ::: You can disable the summary by configuring the reporter: @@ -655,21 +655,24 @@ export default defineConfig({ }) ``` -### Agent Reporter +### Minimal Reporter -Outputs a minimal report optimized for AI coding assistants and LLM-based workflows. Only failed tests and their error messages are displayed. Console logs from passing tests and the summary section are suppressed to reduce token usage. +- **Alias:** `agent` -This reporter is automatically enabled when no `reporters` option is configured and Vitest detects it is running inside an AI coding agent. If you configure custom reporters, you can explicitly add `agent`: +Outputs a minimal report containing only failed tests and their error messages. Console logs from passing tests and the summary section are also suppressed. + +::: tip Agent Reporter +This reporter is well optimized for AI coding assistants and LLM-based workflows to reduce token usage. It is automatically enabled when no `reporters` option is configured and Vitest detects it is running inside an AI coding agent. If you configure custom reporters, you can explicitly add `minimal` or `agent`: :::code-group ```bash [CLI] -npx vitest --reporter=agent +npx vitest --reporter=minimal ``` ```ts [vitest.config.ts] export default defineConfig({ test: { - reporters: ['agent'] + reporters: ['minimal'] }, }) ``` From 2aae193f0f78a1bf6e7987cb80dc9950fb739a94 Mon Sep 17 00:00:00 2001 From: Bart Waardenburg Date: Mon, 20 Apr 2026 13:44:11 +0200 Subject: [PATCH 2/2] feat(coverage): istanbul to support `instrumenter` option (#10119) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Ari Perkkiƶ --- config/coverage.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/config/coverage.md b/config/coverage.md index 8d3f2269..461466de 100644 --- a/config/coverage.md +++ b/config/coverage.md @@ -390,6 +390,46 @@ Watermarks for statements, lines, branches and functions. See [istanbul document Concurrency limit used when processing the coverage results. +## coverage.instrumenter 4.1.5 {#coverage-instrumenter} + +- **Type:** `(options: InstrumenterOptions) => CoverageInstrumenter` +- **Available for providers:** `'istanbul'` + +Factory for a custom instrumenter to use in place of the default `istanbul-lib-instrument`. Vitest calls the factory once during initialization and reuses the returned instrumenter for every file. The rest of the Istanbul pipeline (collection, merging, reporting) is unchanged. + +The factory receives an `InstrumenterOptions` object with Vitest's runtime coverage settings, and must return an object implementing the `CoverageInstrumenter` interface. Both types are exported from `vitest/node`. + + +```ts +interface InstrumenterOptions { + coverageVariable: string + coverageGlobalScope: string + coverageGlobalScopeFunc: boolean + ignoreClassMethods: string[] +} + +interface CoverageInstrumenter { + instrumentSync: (code: string, filename: string, inputSourceMap?: any) => string + lastSourceMap: () => any + lastFileCoverage: () => any +} +``` + + +```ts +import { defineConfig } from 'vitest/config' +import { createInstrumenter } from '@vitest/some-custom-instrumenter' + +export default defineConfig({ + test: { + coverage: { + provider: 'istanbul', + instrumenter: options => createInstrumenter(options), + } + } +}) +``` + ## coverage.customProviderModule - **Type:** `string`