You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**Blob reporter** and `--merge-reports`: `.vitest-reports/blob-*.json` → `.vitest/blob/blob-*.json`
183
183
-**HTML reporter** ([`html`](/guide/reporters#html-reporter)): `html/index.html` → `.vitest/index.html`, and its option changed from `outputFile` (a file) to `outputDir` (a directory)
The `json` and `junit` reporters now write to a file by default instead of printing to stdout. If you previously relied on the report being printed to stdout (for example `vitest --reporter=json > out.json` or `vitest --reporter=json | jq`), either read the generated artifact file instead (for example `jq . .vitest/json/output.json`), or opt back into stdout with the reporter's `stdout` option (`reporters: [['json', { stdout: true }]]`). An explicit `outputFile` is still respected and unchanged.
184
188
185
189
### `toMatchScreenshot` Now Uses a Dedicated Screenshot Directory Config
Copy file name to clipboardExpand all lines: docs/guide/reporters.md
+33-3Lines changed: 33 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -60,7 +60,13 @@ export default defineConfig({
60
60
61
61
## Reporter Output
62
62
63
-
By default, Vitest's reporters will print their output to the terminal. When using the `json` or `junit` reporters, you can instead write your tests' output to a file by including an `outputFile`[configuration option](/config/outputfile) either in your Vite configuration file or via CLI. The `html` reporter writes a report directory instead; see its [`outputDir`](#html-reporter) option.
63
+
By default, Vitest's reporters print their output to the terminal. The `json`, `junit` and `html` reporters instead write to a scoped location under `.vitest/`:
64
+
65
+
-`json` writes `.vitest/json/output.json`
66
+
-`junit` writes `.vitest/junit/output.xml`
67
+
-`html` writes `.vitest/index.html`
68
+
69
+
The `json` and `junit` locations can be overridden with the `outputFile`[configuration option](/config/outputfile) in your Vitest configuration file or via CLI. The `html` reporter uses its [`outputDir`](#html-reporter) option instead.
64
70
65
71
:::code-group
66
72
```bash [CLI]
@@ -77,6 +83,30 @@ export default defineConfig({
77
83
```
78
84
:::
79
85
86
+
The `json` and `junit` reporters also accept `outputFile` as a reporter option, which takes precedence over the top-level `outputFile`:
To print the report to the terminal instead of writing it to a file, set the `stdout` option on the `json` or `junit` reporter. This is ignored when `outputFile` is set:
97
+
98
+
```ts [vitest.config.ts]
99
+
exportdefaultdefineConfig({
100
+
test: {
101
+
reporters: [['json', { stdout: true }]],
102
+
},
103
+
})
104
+
```
105
+
106
+
::: warning
107
+
When `stdout` is enabled, the report can be interleaved with other output written directly to the terminal — for example `process.stdout.write` in a test file, or logs from the main process such as a global setup file — which can make the JSON or XML unparsable. Prefer the default file output when you need to consume the report programmatically.
108
+
:::
109
+
80
110
## Combining Reporters
81
111
82
112
You can use multiple reporters simultaneously to print your test results in different formats. For example:
@@ -316,7 +346,7 @@ Example terminal output for a passing test suite:
316
346
317
347
### JUnit Reporter
318
348
319
-
Outputs a report of the test results in JUnit XML format. Can either be printed to the terminal or written to an XML file using the [`outputFile`](/config/outputfile) configuration option.
349
+
Outputs a report of the test results in JUnit XML format. By default it is written to `.vitest/junit/output.xml`. To write it elsewhere, use the [`outputFile`](/config/outputfile) configuration option or the reporter's own `outputFile` option. To print it to the terminal instead, set the reporter's [`stdout`](#reporter-output) option.
320
350
321
351
:::code-group
322
352
```bash [CLI]
@@ -420,7 +450,7 @@ export default defineConfig({
420
450
421
451
### JSON Reporter
422
452
423
-
Generates a report of the test results in a JSON format compatible with Jest's `--json` option. Can either be printed to the terminal or written to a file using the [`outputFile`](/config/outputfile) configuration option.
453
+
Generates a report of the test results in a JSON format compatible with Jest's `--json` option. By default it is written to `.vitest/json/output.json`. To write it elsewhere, use the [`outputFile`](/config/outputfile) configuration option or the reporter's own `outputFile` option. To print it to the terminal instead, set the reporter's [`stdout`](#reporter-output) option.
0 commit comments