From 0144046c07d724a896ed3b560b8d9ed80ef718d3 Mon Sep 17 00:00:00 2001 From: iliya Date: Tue, 3 Mar 2026 01:22:36 +0200 Subject: [PATCH] fix: use vi.stubEnv for HOME instead of stubbing process Stubbing process breaks vitest internals (process.listeners) in workers. stubEnv only overrides the env var and leaves process intact. Made-with: Cursor --- test/setup.ts | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/test/setup.ts b/test/setup.ts index 9984d4b6..1cc3cc1b 100644 --- a/test/setup.ts +++ b/test/setup.ts @@ -5,18 +5,9 @@ import { afterEach, beforeEach, expect, vi } from 'vitest'; -// Mock process.env for tests that need home directory. -// Use Proxy so process keeps all methods (listeners, on, etc.) — spreading loses them. -const testEnv = { ...process.env, HOME: '/home/testuser' }; -vi.stubGlobal( - 'process', - new Proxy(process, { - get(target, prop) { - if (prop === 'env') return testEnv; - return (target as Record)[prop]; - }, - }) -); +// Mock HOME for tests that need a predictable home path. Use stubEnv so we never +// touch process itself — stubbing process breaks vitest (process.listeners etc). +vi.stubEnv('HOME', '/home/testuser'); let errorSpy: ReturnType; let warnSpy: ReturnType;