import { vi } from 'vitest'; // Mock localStorage const localStorageMock: Storage = { get length() { return 0; }, key: vi.fn(() => null), getItem: vi.fn(), setItem: vi.fn(), removeItem: vi.fn(), clear: vi.fn(), }; global.localStorage = localStorageMock; // Mock fetch global.fetch = vi.fn(); // Mock window global.window = { addEventListener: vi.fn(), removeEventListener: vi.fn(), dispatchEvent: vi.fn(), CustomEvent: class CustomEvent { type: string; detail: unknown; constructor(type: string, options?: { detail?: unknown }) { this.type = type; this.detail = options?.detail; } }, } as unknown as Window & typeof globalThis; // Mock import.meta.env Object.defineProperty(global, 'import', { value: { meta: { env: { VITE_API_URL: 'http://localhost:3000/api', }, }, }, writable: true, }); // Cleanup after each test afterEach(() => { vi.clearAllMocks(); });