Skip to content

Commit bc941d2

Browse files
committed
fix(tests): preserve process.env proxy for Windows
The spread operator {...process.env} breaks Windows environment variable handling because it loses the special proxy behavior that Node.js uses for process.env. On Windows, environment variables are case-insensitive and accessed through a proxy that the spread operator doesn't preserve. This was causing tests to produce empty CLI output on Windows runners because critical environment variables weren't properly passed to spawned processes. Changes: - Set VITEST='1' directly on process.env instead of spreading - Restore processEnv to direct process.env reference - Add comments explaining Windows compatibility requirement This reverts processEnv behavior to match commit 39ee946 which had working Windows tests. Fixes: Empty CLI output in Windows CI tests (504 test failures)
1 parent 9a5a222 commit bc941d2

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

packages/cli/test/utils.mts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,18 @@ import {
1616
const __filename = fileURLToPath(import.meta.url)
1717
const __dirname = path.dirname(__filename)
1818

19+
// Set VITEST environment variable for test runs.
20+
// This disables interactive help menus in spawned CLI processes.
21+
// Must be set on process.env directly (not spread) to preserve
22+
// Windows environment variable proxy behavior.
23+
if (!process.env['VITEST']) {
24+
process.env['VITEST'] = '1'
25+
}
26+
1927
// Backward compatibility object for tests.
2028
const constants = {
2129
execPath,
22-
processEnv: {
23-
...process.env,
24-
// Disable interactive help menu in spawned CLI processes during tests.
25-
VITEST: '1',
26-
},
30+
processEnv: process.env,
2731
}
2832

2933
// The asciiUnsafeRegexp match characters that are:

0 commit comments

Comments
 (0)