- Replace <img> with Next.js <Image> in not-found.tsx - Add console mock in jest.setup.js to silence logs during tests 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
41 lines
974 B
JavaScript
41 lines
974 B
JavaScript
// Learn more: https://github.com/testing-library/jest-dom
|
|
import '@testing-library/jest-dom';
|
|
|
|
// Silence console output during tests
|
|
const originalConsole = { ...console };
|
|
beforeAll(() => {
|
|
jest.spyOn(console, 'log').mockImplementation(() => {});
|
|
jest.spyOn(console, 'warn').mockImplementation(() => {});
|
|
jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
});
|
|
|
|
afterAll(() => {
|
|
console.log = originalConsole.log;
|
|
console.warn = originalConsole.warn;
|
|
console.error = originalConsole.error;
|
|
});
|
|
|
|
// 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.NEXT_PUBLIC_API_URL = 'http://localhost:4000/api';
|