From 4d471ef7beec1ede8a9c1dc306d68c4da52fe0ab Mon Sep 17 00:00:00 2001 From: iliya Date: Tue, 3 Mar 2026 01:21:23 +0200 Subject: [PATCH] fix: preserve process methods in test setup to avoid vitest worker crash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Stub process with Proxy instead of spread — spreading loses inherited methods (listeners, on, etc.), causing process.listeners is not a function and ERR_IPC_CHANNEL_CLOSED in CI on Windows. Made-with: Cursor --- test/setup.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/test/setup.ts b/test/setup.ts index aca6a909..194e2e97 100644 --- a/test/setup.ts +++ b/test/setup.ts @@ -5,14 +5,18 @@ import { afterEach, beforeEach, expect, vi } from 'vitest'; -// Mock process.env for tests that need home directory -vi.stubGlobal('process', { - ...process, - env: { - ...process.env, - HOME: '/home/testuser', - }, -}); +// 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]; + }, + }) +); let errorSpy: ReturnType; let warnSpy: ReturnType;