← back to Wine Finder Next
jest.setup.js
38 lines
// Learn more: https://github.com/testing-library/jest-dom
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(),
pathname: '/',
query: {},
asPath: '/',
}
},
usePathname() {
return '/'
},
useSearchParams() {
return new URLSearchParams()
},
}))
// Mock environment variables
process.env.NODE_ENV = 'test'
process.env.NEXT_PUBLIC_API_URL = 'http://localhost:3000'
// Global test timeout
jest.setTimeout(10000)
// Suppress console errors in tests (optional)
global.console = {
...console,
error: jest.fn(),
warn: jest.fn(),
}