diff --git a/tests/lib/state-store.test.js b/tests/lib/state-store.test.js index 80ac95ec9..bf0a26c09 100644 --- a/tests/lib/state-store.test.js +++ b/tests/lib/state-store.test.js @@ -38,12 +38,19 @@ function cleanupTempDir(dirPath) { fs.rmSync(dirPath, { recursive: true, force: true }); } +// The status CLI reconciles install-state found under $HOME, so CLI runs get an +// empty home instead of the developer's real ~/.claude. +const ISOLATED_HOME = createTempDir('ecc-state-home-'); +process.on('exit', () => cleanupTempDir(ISOLATED_HOME)); + function runNode(scriptPath, args = [], options = {}) { return spawnSync('node', [scriptPath, ...args], { encoding: 'utf8', cwd: options.cwd || process.cwd(), env: { ...process.env, + HOME: ISOLATED_HOME, + USERPROFILE: ISOLATED_HOME, ...(options.env || {}), }, });