From acfa18b9697d9d17347dfc3dd556ca3b2d7cf6c2 Mon Sep 17 00:00:00 2001 From: dprevost-perso Date: Thu, 8 Oct 2026 22:08:16 -0400 Subject: [PATCH] test: write the Vitest HTML report only on request The html reporter ran on every unit test run, also in CI, and wrote a report of several MB to .vitest-ui/ that nobody opened there. It now runs only with the new test:unit:report script. test:unit:ui (the live Vitest UI) does not need it. Co-Authored-By: Claude Opus 5.5 --- package.json | 1 + vitest.config.ts | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 5e33ab3c..ac3927c4 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "lint:fix": "oxlint --fix packages tests", "test:types": "tsc -p tests/tsconfig.json --noEmit", "test:unit": "vitest --coverage --run", + "test:unit:report": "cross-env VITEST_HTML_REPORT=true vitest --coverage --run", "test:unit:ui": "vitest --coverage --ui", "test:unit:watch": "vitest --coverage --watch", "test.local.init": "rimraf localBaseline && SAVE_ACTUAL=true wdio ./tests/configs/wdio.local.init.conf.ts", diff --git a/vitest.config.ts b/vitest.config.ts index decd2863..baa6025f 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -3,7 +3,10 @@ import { defineConfig, coverageConfigDefaults, defaultExclude } from 'vitest/con export default defineConfig({ test: { include: ['./packages/**/(tests|src)/**/*.test.ts'], - reporters: ['default', ['html', { outputDir: '.vitest-ui' }]], + // The static HTML report (.vitest-ui/) is written only on request (`pnpm test:unit:report`), not on every run + reporters: process.env.VITEST_HTML_REPORT === 'true' + ? ['default', ['html', { outputDir: '.vitest-ui' }]] + : ['default'], coverage: { // Vitest 4 removed `coverage.all`: without `include`, only the files that the tests load are reported include: ['packages/*/src/**/*.{ts,tsx}'],