const nextJest = require('next/jest') const createJestConfig = nextJest({ // Provide the path to your Next.js app to load next.config.js and .env files dir: './', }) // Unit tests configuration - runs in Node.js environment const unitJestConfig = { displayName: 'Unit Tests', setupFilesAfterEnv: ['/jest.setup.js'], moduleNameMapper: { // Handle module aliases '^@/(.*)$': '/src/$1', }, testEnvironment: 'jest-environment-jsdom', collectCoverageFrom: [ 'src/**/*.{js,jsx,ts,tsx}', '!src/**/index.ts', '!src/**/*.d.ts', '!src/__tests__/**', ], testPathIgnorePatterns: [ '/.next/', '/node_modules/', '/src/__tests__/integration.test.ts', '/src/__tests__/e2e-docker.test.ts', '/src/__tests__/browser-integration.test.ts' ], testMatch: [ '/src/**/*.test.{js,jsx,ts,tsx}', '/src/**/*.unit.test.{js,jsx,ts,tsx}' ] } // createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async module.exports = createJestConfig(unitJestConfig)