import type { Config } from 'jest' import nextJest from 'next/jest.js' const createJestConfig = nextJest({ // Provide the path to your Next.js app to load next.config.js and .env files in your test environment dir: './', }) // Production-specific Jest config const config: Config = { coverageProvider: 'babel', testEnvironment: 'jsdom', setupFilesAfterEnv: ['/jest.setup.ts'], testPathIgnorePatterns: ['/node_modules/', '/__mocks__/', '/.next/'], // Skip problematic tests in production testMatch: [ '**/__tests__/**/*.test.{js,jsx,ts,tsx}', '!**/__tests__/components/**/*.test.{js,jsx,ts,tsx}', '!**/__tests__/not-found.test.{js,jsx,ts,tsx}', '!**/__tests__/api/email.test.{js,jsx,ts,tsx}', '!**/__tests__/api/sitemap.test.{js,jsx,ts,tsx}', '!**/__tests__/api/fetchAllProjects.test.{js,jsx,ts,tsx}', '!**/__tests__/api/fetchProject.test.{js,jsx,ts,tsx}', '!**/__tests__/sitemap.xml/**/*.test.{js,jsx,ts,tsx}', ], // Production build fixes testEnvironmentOptions: { customExportConditions: [''], }, // Module resolution moduleNameMapper: { '^@/(.*)$': '/$1', }, // Fix haste collision haste: { hasteImplModulePath: undefined, }, modulePathIgnorePatterns: ['/.next/'], // Mock management clearMocks: true, resetMocks: true, restoreMocks: true, // Transform patterns transformIgnorePatterns: [ 'node_modules/(?!(react-markdown|remark-.*|rehype-.*|unified|bail|is-plain-obj|trough|vfile|vfile-message|unist-.*|micromark|parse-entities|character-entities|mdast-.*|hast-.*|property-information|space-separated-tokens|comma-separated-tokens|web-namespaces|zwitch|longest-streak|ccount)/)' ], // Global setup for production globals: { 'process.env.NODE_ENV': 'test', }, } export default createJestConfig(config)