const config = { // A list of paths to directories that Jest should use to search for files in // https://jestjs.io/docs/configuration#roots-arraystring roots: ['/app/'], // The test environment that will be used for testing, jsdom for browser environment // https://jestjs.io/docs/configuration#testenvironment-string testEnvironment: 'jsdom', // Jest transformations // https://jestjs.io/docs/configuration#transform-objectstring-pathtotransformer--pathtotransformer-object transform: { '^.+\\.tsx?$': 'ts-jest', // Transform TypeScript files using ts-jest }, // A list of paths to modules that run some code to configure or set up the testing framework before each test file in the suite is executed // https://jestjs.io/docs/configuration#setupfilesafterenv-array setupFilesAfterEnv: ['/jest.setup.ts'], // Code coverage config // https://jestjs.io/docs/configuration#collectcoveragefrom-array coverageDirectory: '/coverage/', collectCoverageFrom: ['/app/**/*.{ts,tsx}', '!**/node_modules/**', '!**/*.d.ts'], // Important: order matters, specific rules should be defined first // https://jestjs.io/fr/docs/configuration#modulenamemapper-objectstring-string--arraystring moduleNameMapper: { // Style imports have no meaning under Jest '\\.(css|scss|sass)$': '/app/__mocks__/styleMock.ts', // react-markdown is ESM-only and cannot be required by Jest's CommonJS runtime '^react-markdown$': '/app/__mocks__/reactMarkdown.tsx', // app/hmr.ts uses import.meta.hot, which TypeScript refuses to compile to the CommonJS // module ts-jest forces for Jest (TS1343); swap in the no-op mock instead '^app/hmr$': '/app/__mocks__/hmr.ts', // app/ absolute module alias 'app/(.*)': '/app/$1', }, testTimeout: 30000, clearMocks: true, }; export default config;