Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Vitest 3.x reference skill covering configuration, test/describe APIs, mocking, coverage, snapshots, and concurrency.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/features-reporters.md
1---2name: reporters3description: Built-in reporters, default selection, and CI/output configuration4---56# Reporters78Select reporters via `--reporter` or `reporters` config. Configuring `reporters` **replaces** the default list — spread `configDefaults.reporters` to keep them.910```ts11import { configDefaults, defineConfig } from 'vitest/config'1213export default defineConfig({14test: {15reporters: ['verbose', ['junit', { suiteName: 'UI tests' }]],16// keep defaults and add one:17// reporters: ['json', ...configDefaults.reporters],18},19})20```2122## Default Selection2324When `reporters` is unset, Vitest auto-selects:2526- `default` for normal terminal runs27- **`minimal` (alias `agent`)** when it detects an **AI coding agent** — only failed tests + errors, no summary or passing logs, optimized to cut token usage28- `github-actions` is added when `process.env.GITHUB_ACTIONS === 'true'`2930## Built-in Reporters3132| Reporter | Use |33|----------|-----|34| `default` | Summary + collapses passing files; prints full tree for single/failing file |35| `verbose` | One line per finished test (flat list in v4); only reporter that shows annotations on pass |36| `tree` | Like `default` but always shows each test (the old v3 verbose) |37| `dot` | One dot per test; details only for failures |38| `minimal` / `agent` | Failures only; best for AI/LLM workflows |39| `junit` | JUnit XML (templated, see below) |40| `json` | Jest-compatible JSON; includes `coverageMap` when coverage enabled |41| `tap` / `tap-flat` | TAP (nested / flat) |42| `html` | Interactive UI report (needs `@vitest/ui`) |43| `blob` | Serialized results for `--merge-reports` |44| `github-actions` | Workflow annotations + job summary |45| `hanging-process` | Lists processes preventing exit (debugging) |4647> v4 removed the `basic` reporter (equivalent to `['default', { summary: false }]`). The old `verbose` flat behavior moved here; use `tree` for the nested view.4849## Output Files5051```bash52vitest --reporter=json --outputFile=./test-output.json53```5455```ts56defineConfig({57test: {58reporters: ['junit', 'json'],59outputFile: { junit: './junit.xml', json: './report.json' },60},61})62```6364## JUnit Templating6566```ts67reporters: [['junit', {68suiteNameTemplate: '{title}', // {title} {filename} {basename} {displayName}69classnameTemplate: '{classname}', // {classname} {title} {suitename} {filename} ...70titleTemplate: '{title}',71ancestorSeparator: ' > ',72addFileAttribute: true,73}]]74```7576`{filename}` is the **relative** path (use `{basename}` for the bare name). Templates can also be functions receiving all variables.7778## HTML Report (v5 paths)7980The HTML reporter writes a directory via `outputDir` (default `.vitest`); the entry is `<outputDir>/index.html`. Use `singleFile: true` for a self-contained shareable file (large; coverage not inlined).8182```ts83reporters: [['html', { singleFile: true }]]84```8586## Blob & Merge (CI/sharding)8788Blobs default to `.vitest/blob/`. Label environments with `VITEST_BLOB_LABEL` or the reporter `label` option:8990```bash91vitest run --reporter=blob --outputFile=reports/blob-1.json92vitest --merge-reports=reports --reporter=junit --reporter=default93```9495Blob reports don't include file attachments — merge `attachmentsDir` (`.vitest/attachments/`) separately. `--reporter=blob`/`--merge-reports` don't work in watch mode.9697## Key Points9899- Configuring `reporters` replaces defaults — spread `configDefaults.reporters` to keep them100- The `minimal`/`agent` reporter is auto-selected for AI agents and minimizes token usage101- Use `tree` for the nested per-test view (old v3 `verbose`)102- v5 artifacts (blob, attachments, HTML) live under `.vitest/`103104<!--105Source references:106- https://vitest.dev/guide/reporters107- https://vitest.dev/config/reporters108-->109