From 273ec3b1ce30190ee299a3e815d0efc21e30e6c8 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 1 Sep 2026 10:19:06 +0000 Subject: [PATCH] Exclude the tsc build output from vitest instead of from the build Excluding src/common tests from tsconfig.common.json kept vitest from running the compiled copies twice, but it also meant those test files were no longer type checked at all by `tsc --build` (eslint only catches lint issues, not type errors). Exclude common-ts-dist from test discovery instead, so the tests are both type checked and run exactly once. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01YCf7BBiPqNLUjVoN7rTCF6 --- tsconfig.common.json | 5 ----- tsconfig.node.json | 1 + vitest.config.ts | 9 +++++++++ 3 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 vitest.config.ts diff --git a/tsconfig.common.json b/tsconfig.common.json index 886ae832..eda60050 100644 --- a/tsconfig.common.json +++ b/tsconfig.common.json @@ -16,9 +16,4 @@ "include": [ "src/common/**/*", ], - // tests are run by vitest from the sources; don't emit them into the build output, - // or vitest would discover and run the compiled copies too - "exclude": [ - "src/common/**/*.test.ts", - ], } \ No newline at end of file diff --git a/tsconfig.node.json b/tsconfig.node.json index 4b807e3f..31f8154c 100644 --- a/tsconfig.node.json +++ b/tsconfig.node.json @@ -11,6 +11,7 @@ }, "include": [ "electron.vite.config.ts", + "vitest.config.ts", "i18next.config*.ts", "script/**/*", ], diff --git a/vitest.config.ts b/vitest.config.ts new file mode 100644 index 00000000..b624cd45 --- /dev/null +++ b/vitest.config.ts @@ -0,0 +1,9 @@ +import { configDefaults, defineConfig } from 'vitest/config'; + +export default defineConfig({ + test: { + // `tsc --build` compiles src/common (tests included) into common-ts-dist. Don't discover those + // compiled copies, or every test in src/common would also run a second time from the build output. + exclude: [...configDefaults.exclude, 'common-ts-dist/**'], + }, +});