import nextJest from 'next/jest' import type { Config } from 'jest' 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 customJestConfig: Config = { setupFilesAfterEnv: ['/jest.setup.ts'], testEnvironment: 'jsdom', testPathIgnorePatterns: ['/node_modules/', '/.next/'], transform: { '^.+\\.(js|jsx|ts|tsx)$': ['babel-jest', { presets: ['next/babel'] }], }, moduleNameMapper: { '^@/(.*)$': '/src/$1', }, } // createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async export default createJestConfig(customJestConfig)