Skip to content

Commit edc5df8

Browse files
authored
test: run every test file against a throwaway home (#62)
The in-process runtime tests collect through fake connectors and never isolated the CLI folder, so every run wrote their fixtures into the real ~/.vana/results of whoever ran the suite: on 2026-09-25 they replaced a real GitHub and Oura export on a developer machine with "tester" stubs. A setup file now points HOME at a fresh temp dir per test file, so ~/.vana, ~/.claude and the rest land there; tests that set their own HOME still win. Verified: a full run leaves the real ~/.vana/results untouched. Claude-Session: https://claude.ai/code/session_01Fcv6uEy4zcXaigzDNxeW3j
1 parent d784f64 commit edc5df8

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

‎test/setup/isolate-home.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import fs from "node:fs";
2+
import os from "node:os";
3+
import path from "node:path";
4+
5+
// Every test file runs against its own throwaway home. Tests that forgot to
6+
// isolate themselves wrote connector results into the real ~/.vana/results
7+
// of whoever ran the suite (fixtures replaced a real GitHub and Oura export
8+
// on 2026-09-25). os.homedir() follows HOME, so ~/.vana, ~/.claude and the
9+
// rest land here; tests that set their own HOME or VANA_HOME still win.
10+
const home = fs.mkdtempSync(path.join(os.tmpdir(), "vana-test-home-"));
11+
process.env.HOME = home;
12+
process.env.USERPROFILE = home;
13+
delete process.env.VANA_HOME;

‎vitest.config.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export default defineConfig({
44
test: {
55
globals: true,
66
include: ["test/**/*.test.ts"],
7+
setupFiles: ["test/setup/isolate-home.ts"],
78
coverage: {
89
provider: "v8",
910
include: ["src/**/*.ts", "src/**/*.tsx"],

0 commit comments

Comments
 (0)