import type { Config } from 'jest'; import nextJest from 'next/jest.js'; // const nextJest = require('next/jest'); const createJestConfig = nextJest({ // Provide the path to your Next.js app to load next.config.* and .env files in your test environment dir: './', }); // Add any custom config to be passed to Jest const customJestConfig: Config = { coverageProvider: 'v8', setupFilesAfterEnv: ['/jest.setup.ts'], moduleNameMapper: { // Handle the `@/*` alias — it maps to `src/*` (see tsconfig.json), so jest.mock('@/…') // and imports resolve to the same files the app uses. '^@/(.*)$': '/src/$1', }, // testEnvironment: 'jest-environment-jsdom', testEnvironment: 'jsdom', // transform: { // '.+\\.(css|styl|less|sass|scss)$': 'jest-css-modules-transform', // }, }; // createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async module.exports = createJestConfig(customJestConfig);