Skip to content

Commit 4715138

Browse files
authored
fix: set USERPROFILE for Windows compatibility in telemetry tests (Fission-AI#469)
On Windows, os.homedir() uses the USERPROFILE environment variable instead of HOME. The telemetry config tests were only mocking HOME, causing them to fail on Windows CI.
1 parent 940898c commit 4715138

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

test/telemetry/config.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,25 @@ import {
1414
describe('telemetry/config', () => {
1515
let tempDir: string;
1616
let originalHome: string | undefined;
17+
let originalUserProfile: string | undefined;
1718

1819
beforeEach(() => {
1920
// Create temp directory for tests
2021
tempDir = path.join(os.tmpdir(), `openspec-telemetry-test-${Date.now()}`);
2122
fs.mkdirSync(tempDir, { recursive: true });
2223

23-
// Mock HOME to point to temp dir
24+
// Mock HOME/USERPROFILE to point to temp dir
25+
// On POSIX, os.homedir() uses HOME; on Windows it uses USERPROFILE
2426
originalHome = process.env.HOME;
27+
originalUserProfile = process.env.USERPROFILE;
2528
process.env.HOME = tempDir;
29+
process.env.USERPROFILE = tempDir;
2630
});
2731

2832
afterEach(() => {
29-
// Restore HOME
33+
// Restore HOME/USERPROFILE
3034
process.env.HOME = originalHome;
35+
process.env.USERPROFILE = originalUserProfile;
3136

3237
// Clean up temp directory
3338
fs.rmSync(tempDir, { recursive: true, force: true });

0 commit comments

Comments
 (0)