What
Running the unit suite on Windows pollutes — and can destroy — the developer's real ~/.insta/config.json.
Proven on a real windows-latest runner (run 32407886883, job unit-tests-windows): test/ensure-skills.test.ts failed expecting InsForge/insta-skills but got InsForge/insta-skills#devel — on a fresh runner that had never touched staging.
Why
src/config.ts resolves GLOBAL_DIR from os.homedir() at import time.
test/env-switch.test.ts isolates by setting process.env.HOME to a temp dir (+ vi.resetModules()). That works on macOS/Linux, but on Windows os.homedir() reads USERPROFILE, so the override is a no-op and every write in that suite lands in the runner's real %USERPROFILE%\.insta\config.json — including tests that persist a staging apiUrl.
test/ensure-skills.test.ts does no HOME isolation at all; installSkills → resolveEnv() reads whatever the real config says. After the env-switch suite has polluted it → #devel → assertion failure. (This is also why the ensure-skills/setup tests fail on any dev machine whose real config points at staging, on any OS.)
Impact
- Windows CI for the unit suite is flaky/false-failing (product paths are fine — the setup-agent e2e passed on the same runners in both PowerShell and cmd).
- A contributor running
npm test on Windows gets their real ~/.insta/config.json overwritten with test data — logged-out at best, silently re-pointed at a test apiUrl at worst.
Fix sketch
env-switch.test.ts: set USERPROFILE (and HOME) to the temp dir in beforeEach, restore both in afterEach.
ensure-skills.test.ts (and the setup tests that hit resolveEnv): isolate the same way, or inject the skills spec instead of reading the machine's config.
- Optionally make
config.ts read the home dir lazily via a function so tests don't depend on vi.resetModules() import-time tricks.
Found while e2e-verifying npx -y insta setup agent (#110) on Windows.
What
Running the unit suite on Windows pollutes — and can destroy — the developer's real
~/.insta/config.json.Proven on a real
windows-latestrunner (run 32407886883, jobunit-tests-windows):test/ensure-skills.test.tsfailed expectingInsForge/insta-skillsbut gotInsForge/insta-skills#devel— on a fresh runner that had never touched staging.Why
src/config.tsresolvesGLOBAL_DIRfromos.homedir()at import time.test/env-switch.test.tsisolates by settingprocess.env.HOMEto a temp dir (+vi.resetModules()). That works on macOS/Linux, but on Windowsos.homedir()readsUSERPROFILE, so the override is a no-op and every write in that suite lands in the runner's real%USERPROFILE%\.insta\config.json— including tests that persist a stagingapiUrl.test/ensure-skills.test.tsdoes no HOME isolation at all;installSkills→resolveEnv()reads whatever the real config says. After the env-switch suite has polluted it →#devel→ assertion failure. (This is also why the ensure-skills/setup tests fail on any dev machine whose real config points at staging, on any OS.)Impact
npm teston Windows gets their real~/.insta/config.jsonoverwritten with test data — logged-out at best, silently re-pointed at a test apiUrl at worst.Fix sketch
env-switch.test.ts: setUSERPROFILE(andHOME) to the temp dir inbeforeEach, restore both inafterEach.ensure-skills.test.ts(and the setup tests that hitresolveEnv): isolate the same way, or inject the skills spec instead of reading the machine's config.config.tsread the home dir lazily via a function so tests don't depend onvi.resetModules()import-time tricks.Found while e2e-verifying
npx -y insta setup agent(#110) on Windows.