From d6cea577c9fdedc374ca5be2751d703c7c36a079 Mon Sep 17 00:00:00 2001 From: toanhoang Date: Mon, 3 Aug 2026 19:54:49 -0400 Subject: [PATCH] fix: scope vitest to tests/ dir to avoid picking up stray worktree checkouts Vitest's default glob isn't excluded for .claude/, so a sibling worktree under .claude/worktrees/ (e.g. worktree-ui-basic) got silently collected and run against this repo's current src/ via the "@" alias, doubling the test count and running a stale test file against current code under a shared identity. Found by an independent test-runner pass while verifying the Assignment transfer fix. --- vitest.config.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/vitest.config.ts b/vitest.config.ts index c30412e..0c6032f 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -9,6 +9,16 @@ export default defineConfig({ }, test: { environment: "node", + // Scope explicitly to this repo's own tests/ dir — without this, Vitest's + // default glob also picks up any stray sibling git worktree checked out + // under .claude/worktrees/ (e.g. worktree-ui-basic), which isn't excluded + // by Vitest's defaults since those only skip node_modules/.git/etc, not + // .claude/. A stray worktree's stale test file still resolves the "@" + // alias to *this* repo's src/ (see resolve.alias above, which is + // __dirname-relative), so it silently runs old tests against current + // code under a shared identity — confirmed happening in practice once a + // second worktree existed. + include: ["tests/**/*.test.ts"], setupFiles: ["./tests/setup.ts"], // Each test file spins up its own throwaway Postgres database by // mutating process.env.DATABASE_URL in tests/setup.ts's beforeAll (see