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}'],