import '@testing-library/jest-dom'; // Mock Next.js router jest.mock('next/navigation', () => ({ useRouter() { return { push: jest.fn(), replace: jest.fn(), prefetch: jest.fn(), back: jest.fn(), forward: jest.fn(), refresh: jest.fn(), }; }, useSearchParams() { return new URLSearchParams(); }, usePathname() { return '/'; }, })); // Mock Next.js image jest.mock('next/image', () => ({ __esModule: true, default: (props) => { // eslint-disable-next-line @next/next/no-img-element return ; }, })); // Mock Supabase - will be mocked in individual test files // Mock environment variables process.env.NEXT_PUBLIC_SUPABASE_URL = 'https://test.supabase.co'; process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY = 'test-anon-key'; // Global test utilities global.ResizeObserver = jest.fn().mockImplementation(() => ({ observe: jest.fn(), unobserve: jest.fn(), disconnect: jest.fn(), })); // Mock window.matchMedia Object.defineProperty(window, 'matchMedia', { writable: true, value: jest.fn().mockImplementation(query => ({ matches: false, media: query, onchange: null, addListener: jest.fn(), // deprecated removeListener: jest.fn(), // deprecated addEventListener: jest.fn(), removeEventListener: jest.fn(), dispatchEvent: jest.fn(), })), }); // Mock IntersectionObserver global.IntersectionObserver = jest.fn().mockImplementation(() => ({ observe: jest.fn(), unobserve: jest.fn(), disconnect: jest.fn(), })); // Mock NextRequest and NextResponse for API routes global.Request = global.Request || class Request { constructor(input, init) { this.url = typeof input === 'string' ? input : input.url; this.method = init?.method || 'GET'; this.headers = new Map(Object.entries(init?.headers || {})); this._body = init?.body; } async json() { return JSON.parse(this._body); } async text() { return this._body; } }; global.Response = global.Response || class Response { constructor(body, init) { this.body = body; this.status = init?.status || 200; this.statusText = init?.statusText || 'OK'; this.headers = new Map(Object.entries(init?.headers || {})); } async json() { return JSON.parse(this.body); } };