import '@testing-library/jest-dom' import { expect, afterEach, vi } from 'vitest' import { cleanup } from '@testing-library/react' // Cleanup after each test afterEach(() => { cleanup() }) // Mock next/navigation vi.mock('next/navigation', () => ({ useRouter: () => ({ push: vi.fn(), replace: vi.fn(), prefetch: vi.fn(), back: vi.fn(), }), usePathname: () => '/dashboard', useSearchParams: () => new URLSearchParams(), })) // Mock next/image // Using React.createElement avoids JSX in a .ts file (esbuild would refuse). import React from 'react' vi.mock('next/image', () => ({ default: (props: any) => React.createElement('img', props), })) // Suppress console errors in tests (optional) const originalError = console.error beforeAll(() => { console.error = (...args: any[]) => { if ( typeof args[0] === 'string' && args[0].includes('Warning: ReactDOM.render') ) { return } originalError.call(console, ...args) } }) afterAll(() => { console.error = originalError })