···88- **Type:** `string | Record<string, string>`
99- **CLI:** `--outputFile=<path>`, `--outputFile.json=./path`
10101111-Write test results to a file when the `--reporter=json`, `--reporter=html` or `--reporter=junit` option is also specified.
1111+Write test results to a file when the `--reporter=json` or `--reporter=junit` option is also specified.
1212By providing an object instead of a string you can define individual outputs when using multiple reporters.
+8
docs/guide/migration.md
···174174175175If you manually opened the browser preview by copying the Vite server URL or visiting `/__vitest_test__/` directly, use the URL opened or printed by Vitest instead.
176176177177+### Generated Reports and Artifacts Use the `.vitest` Directory
178178+179179+Vitest now uses a single `.vitest` directory at the project root as the shared artifact root, so one `.vitest` entry in `.gitignore` is enough. Defaults that moved this major:
180180+181181+- **Attachments** ([`attachmentsDir`](/config/attachmentsdir)): `.vitest-attachements/` → `.vitest/attachments/`
182182+- **Blob reporter** and `--merge-reports`: `.vitest-reports/blob-*.json` → `.vitest/blob/blob-*.json`
183183+- **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)
184184+177185## Migrating to Vitest 4.0 {#vitest-4}
178186179187::: warning Prerequisites
+2-2
docs/guide/reporters.md
···60606161## Reporter Output
62626363-By default, Vitest's reporters will print their output to the terminal. When using the `json`, `html` 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.
6363+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.
64646565:::code-group
6666```bash [CLI]
···506506507507Generates an HTML file to view test results through an interactive [GUI](/guide/ui). After the file has been generated, Vitest will keep a local development server running and provide a link to view the report in a browser.
508508509509-Output file can be specified using the [`outputFile`](/config/outputfile) configuration option. If no `outputFile` option is provided, a new HTML file will be created.
509509+The report artifact root can be specified using the reporter's `outputDir` option. The report entry is written to `<outputDir>/index.html` and the UI assets files live under `<outputDir>/ui/`. By default `outputDir` is `.vitest`, the shared Vitest artifact directory, so attachments (`.vitest/attachments`) and coverage (`.vitest/coverage`) are reused without being copied.
510510511511:::code-group
512512```bash [CLI]
+4-4
docs/guide/ui.md
···5151To preview your HTML report, you can use the [vite preview](https://vitejs.dev/guide/cli.html#vite-preview) command:
52525353```sh
5454-npx vite preview --outDir ./html
5454+npx vite preview --outDir .vitest
5555```
56565757-You can configure output with [`outputFile`](/config/outputfile) config option. You need to specify `.html` path there. For example, `./html/index.html` is the default value.
5757+You can configure the output location with the HTML reporter's `outputDir` option. It points to the report artifact root, and the report entry is written to `<outputDir>/index.html`. The default value is `.vitest`, the shared Vitest artifact directory.
5858:::
59596060If you need a portable report that can be opened or shared as one file, see [`singleFile`](/guide/reporters#html-reporter) in the HTML reporter documentation.
···6767 id: upload-report
6868 with:
6969 name: vitest-report
7070- path: html/
7070+ path: .vitest/
71717272- name: Viewer link in summary
7373 run: echo "[View HTML report](https://viewer.vitest.dev/?url=${{ steps.upload-report.outputs.artifact-url }})" >> $GITHUB_STEP_SUMMARY
···8080```yaml
8181- uses: actions/upload-artifact@v7
8282 with:
8383- path: html/index.html
8383+ path: .vitest/index.html
8484 archive: false
8585```
8686:::
···11export interface HTMLOptions {
22 /**
33- * Path to the generated HTML report.
33+ * Directory used as the report artifact root.
44 *
55- * @default 'html/index.html'
55+ * The report entry is written to `<outputDir>/index.html` and the UI
66+ * implementation files live under `<outputDir>/ui/`. By default this is the
77+ * shared `.vitest` artifact directory.
88+ *
99+ * @default '.vitest'
610 */
77- outputFile?: string
1111+ outputDir?: string
812 /**
913 * Inline report assets, metadata, and attachments into the generated HTML file.
1014 *
+1-1
packages/vitest/src/node/reporters/utils.ts
···5353 else if (reporterName in ReportersMap) {
5454 const BuiltinReporter
5555 = ReportersMap[reporterName as BuiltinReporters]
5656- return new BuiltinReporter(reporterOptions)
5656+ return new BuiltinReporter(reporterOptions as any)
5757 }
5858 else {
5959 const CustomReporter = await loadCustomReporterModule(
···487487 expect(result3.stderr).toMatchInlineSnapshot(`""`)
488488 expect(result3.stdout).toMatchInlineSnapshot(`
489489 " HTML Report is generated
490490- You can run npx vite preview --outDir html to see the test results.
490490+ You can run npx vite preview --outDir .vitest to see the test results.
491491 "
492492 `)
493493})