Frontend Tests Added: - Jest configuration with TypeScript support - Jest setup with Next.js mocks - Unit tests for lib/metrics.ts (normalizePath, registry) - Unit tests for lib/api-metrics.ts (withMetrics wrapper) - Unit tests for middleware (auth routes, token detection) - Unit tests for API track route (payload validation) Dependencies added: - jest, @testing-library/react, @testing-library/jest-dom - ts-jest, jest-environment-jsdom, @types/jest 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
33 lines
660 B
JavaScript
33 lines
660 B
JavaScript
import '@testing-library/jest-dom';
|
|
|
|
// Mock Next.js router
|
|
jest.mock('next/navigation', () => ({
|
|
useRouter: () => ({
|
|
push: jest.fn(),
|
|
replace: jest.fn(),
|
|
prefetch: jest.fn(),
|
|
back: jest.fn(),
|
|
}),
|
|
useSearchParams: () => ({
|
|
get: jest.fn(),
|
|
}),
|
|
usePathname: () => '/',
|
|
}));
|
|
|
|
// Mock Next.js Image component
|
|
jest.mock('next/image', () => ({
|
|
__esModule: true,
|
|
default: (props) => {
|
|
// eslint-disable-next-line @next/next/no-img-element, jsx-a11y/alt-text
|
|
return <img {...props} />;
|
|
},
|
|
}));
|
|
|
|
// Global fetch mock
|
|
global.fetch = jest.fn(() =>
|
|
Promise.resolve({
|
|
ok: true,
|
|
json: () => Promise.resolve({}),
|
|
})
|
|
);
|