fix(ci): isolate vitest home path
This commit is contained in:
parent
78c49fc631
commit
937b23be4b
2 changed files with 14 additions and 5 deletions
|
|
@ -246,13 +246,13 @@ describe('pathDecoder', () => {
|
||||||
|
|
||||||
describe('getProjectsBasePath', () => {
|
describe('getProjectsBasePath', () => {
|
||||||
it('should return projects base path', () => {
|
it('should return projects base path', () => {
|
||||||
expect(getProjectsBasePath()).toBe(path.join('/home/testuser', '.claude', 'projects'));
|
expect(getProjectsBasePath()).toBe(path.join(defaultHome, '.claude', 'projects'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('getTodosBasePath', () => {
|
describe('getTodosBasePath', () => {
|
||||||
it('should return todos base path', () => {
|
it('should return todos base path', () => {
|
||||||
expect(getTodosBasePath()).toBe(path.join('/home/testuser', '.claude', 'todos'));
|
expect(getTodosBasePath()).toBe(path.join(defaultHome, '.claude', 'todos'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,10 @@
|
||||||
* Runs before each test file.
|
* Runs before each test file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import * as fs from 'fs';
|
||||||
|
import * as os from 'os';
|
||||||
|
import * as path from 'path';
|
||||||
|
|
||||||
import { afterEach, beforeEach, expect, vi } from 'vitest';
|
import { afterEach, beforeEach, expect, vi } from 'vitest';
|
||||||
|
|
||||||
// Mock Sentry Electron SDK — it requires the real `electron` package at import
|
// Mock Sentry Electron SDK — it requires the real `electron` package at import
|
||||||
|
|
@ -19,9 +23,14 @@ vi.mock('@sentry/electron/main', () => sentryNoOp);
|
||||||
vi.mock('@sentry/electron/renderer', () => sentryNoOp);
|
vi.mock('@sentry/electron/renderer', () => sentryNoOp);
|
||||||
vi.mock('@sentry/react', () => sentryNoOp);
|
vi.mock('@sentry/react', () => sentryNoOp);
|
||||||
|
|
||||||
// Mock HOME for tests that need a predictable home path. Use stubEnv so we never
|
// Mock HOME for tests that need a predictable home path. It must be writable:
|
||||||
// touch process itself — stubbing process breaks vitest (process.listeners etc).
|
// some services persist state in best-effort background writes after a test has
|
||||||
vi.stubEnv('HOME', '/home/testuser');
|
// already reset path overrides.
|
||||||
|
const testHomeDir = fs.mkdtempSync(path.join(os.tmpdir(), 'agent-teams-vitest-home-'));
|
||||||
|
vi.stubEnv('HOME', testHomeDir);
|
||||||
|
process.once('exit', () => {
|
||||||
|
fs.rmSync(testHomeDir, { recursive: true, force: true });
|
||||||
|
});
|
||||||
|
|
||||||
let errorSpy: ReturnType<typeof vi.spyOn>;
|
let errorSpy: ReturnType<typeof vi.spyOn>;
|
||||||
let warnSpy: ReturnType<typeof vi.spyOn>;
|
let warnSpy: ReturnType<typeof vi.spyOn>;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue