the-tip-top-frontend/jest.setup.js
soufiane ac8d27ae05 fix: resolve ESLint warning and silence test console output
- 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>
2025-12-01 16:19:27 +01:00

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';