const nextJest = require('next/jest'); /** @type {import('jest').Config} */ const createJestConfig = nextJest({ // Provide the path to your Next.js app to load next.config.js and .env files dir: './', }); // Add any custom config to be passed to Jest const config = { coverageProvider: 'v8', testEnvironment: 'jsdom', // Setup files to run before each test setupFilesAfterEnv: ['/jest.setup.js'], // Test file patterns testMatch: [ '**/__tests__/**/*.(ts|tsx|js)', '**/*.(test|spec).(ts|tsx|js)' ], // Module name mapping for absolute imports (correct property name) moduleNameMapper: { '^@/(.*)$': '/$1', }, // Coverage settings collectCoverageFrom: [ 'app/**/*.{ts,tsx}', 'components/**/*.{ts,tsx}', 'lib/**/*.{ts,tsx}', '!**/*.d.ts', '!**/node_modules/**', '!**/.next/**', '!**/coverage/**', ], // Coverage thresholds coverageThreshold: { global: { branches: 70, functions: 70, lines: 70, statements: 70, }, }, }; // createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async module.exports = createJestConfig(config);