Files
portfolio/jest.config.ts
denshooter 6680d707f1 Refactor CI/CD workflows and configuration files
- Removed unused network configurations from docker-compose.yml.
- Added production-specific Jest configuration in jest.config.production.ts for better test management.
- Updated jest.config.ts to include production build fixes and module resolution improvements.
- Enhanced jest.setup.ts to mock React's act function for production builds.
- Introduced new CI/CD workflows for Gitea, focusing on reliability and zero downtime deployments.
- Added scripts for debugging Gitea Actions and verifying environment variables.

These changes streamline the CI/CD process and improve testing capabilities.
2025-10-15 16:07:35 +02:00

44 lines
1.6 KiB
TypeScript

import type { Config } from 'jest'
import nextJest from 'next/jest.js'
const createJestConfig = nextJest({
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
dir: './',
})
// Add any custom config to be passed to Jest
const config: Config = {
coverageProvider: 'babel',
testEnvironment: 'jsdom',
// Add more setup options before each test is run
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
// Ignore tests inside __mocks__ directory
testPathIgnorePatterns: ['/node_modules/', '/__mocks__/'],
// Transform react-markdown and other ESM modules
transformIgnorePatterns: [
'node_modules/(?!(react-markdown|remark-.*|rehype-.*|unified|bail|is-plain-obj|trough|vfile|vfile-message|unist-.*|micromark|parse-entities|character-entities|mdast-.*|hast-.*|property-information|space-separated-tokens|comma-separated-tokens|web-namespaces|zwitch|longest-streak|ccount)/)'
],
// Fix for production React builds
testEnvironmentOptions: {
customExportConditions: [''],
},
// Module name mapping to fix haste collision
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/$1',
},
// Fix haste collision by excluding .next directory
haste: {
hasteImplModulePath: undefined,
},
// Exclude problematic directories from haste
modulePathIgnorePatterns: ['<rootDir>/.next/'],
// Clear mocks between tests
clearMocks: true,
// Reset modules between tests
resetMocks: true,
// Restore mocks between tests
restoreMocks: true,
}
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
export default createJestConfig(config)