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: './', }) // Integration tests configuration - runs in Node.js environment with fetch polyfill const integrationJestConfig = { displayName: 'Integration Tests', setupFilesAfterEnv: ['/jest.setup.integration.js'], moduleNameMapper: { // Handle module aliases '^@/(.*)$': '/src/$1', }, testEnvironment: 'node', // Node.js environment for real HTTP calls testMatch: [ '/src/__tests__/integration.test.ts', '/src/__tests__/e2e-docker.test.ts' ], testTimeout: 30000, // Longer timeout for integration tests globalSetup: '/jest.globalSetup.integration.js', globalTeardown: '/jest.globalTeardown.integration.js' } // createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async module.exports = createJestConfig(integrationJestConfig)