60 lines
1.1 KiB
JavaScript
60 lines
1.1 KiB
JavaScript
// Jest setup file for global test configuration
|
|
|
|
// Mock Next.js router
|
|
jest.mock('next/router', () => ({
|
|
useRouter() {
|
|
return {
|
|
route: '/',
|
|
pathname: '/',
|
|
query: {},
|
|
asPath: '/',
|
|
push: jest.fn(),
|
|
pop: jest.fn(),
|
|
reload: jest.fn(),
|
|
back: jest.fn(),
|
|
prefetch: jest.fn().mockResolvedValue(undefined),
|
|
beforePopState: jest.fn(),
|
|
events: {
|
|
on: jest.fn(),
|
|
off: jest.fn(),
|
|
emit: jest.fn(),
|
|
},
|
|
isFallback: false,
|
|
};
|
|
},
|
|
}));
|
|
|
|
// Mock Next.js navigation
|
|
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 '/';
|
|
},
|
|
}));
|
|
|
|
// Global test utilities
|
|
global.console = {
|
|
...console,
|
|
// Suppress console.log in tests unless needed
|
|
log: jest.fn(),
|
|
debug: jest.fn(),
|
|
info: jest.fn(),
|
|
warn: jest.fn(),
|
|
error: jest.fn(),
|
|
};
|
|
|
|
// Set up environment variables for tests
|
|
process.env.NODE_ENV = 'test';
|