From 7e0ef86d75ce86668c8fb180679be79a3d402212 Mon Sep 17 00:00:00 2001 From: Jordan Ritter Date: Thu, 25 Jun 2026 11:17:47 -0700 Subject: [PATCH] Scope vitest discovery to src/ so dist twins don't double-run aimock tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The atlas-* aimock tests intermittently failed in CI (9-64 failures, non-deterministic) with `FetchError: Invalid response body ... Premature close` from the in-process aimock LLMock HTTP servers dropping connections under socket pressure — not a distiller JSON-parse bug (that stderr line is benign output from a passing malformed-JSON handling test, mis- correlated because vitest's forks pool shares worker stderr). Root amplifier: the CI `test` job builds dist/ then runs a bare `vitest run` with no config file. Bare vitest globs ALL `*.test.{ts,js}`, so it discovered both `src/__tests__/*.test.ts` and the freshly-compiled `dist/__tests__/*.test.js` twins (plus copies under `.claude/worktrees/*/dist`), running every aimock test multiple times concurrently. That doubled (or worse) the number of simultaneous LLMock servers and the socket/port pressure that triggers "Premature close". A separate `build` job already type-checks the build, so running dist twins in `test` is pure redundancy. Fix: add vitest.config.ts scoping discovery to the source tree and excluding the dist twins and `.claude` worktrees: include: ["src/**/*.test.ts"] exclude: [...configDefaults.exclude, "dist/**", "**/.claude/**"] vitest list before: 23743 dist-twin test cases collected; after: 0 (src still fully collected, 3186 tests pass). --- vitest.config.ts | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 vitest.config.ts diff --git a/vitest.config.ts b/vitest.config.ts new file mode 100644 index 0000000..5ae64bf --- /dev/null +++ b/vitest.config.ts @@ -0,0 +1,8 @@ +import { defineConfig, configDefaults } from "vitest/config"; + +export default defineConfig({ + test: { + include: ["src/**/*.test.ts"], + exclude: [...configDefaults.exclude, "dist/**", "**/.claude/**"], + }, +});