Files
workavia-calendar-front/jest.config.ts
T
lenhanphung 192ab17789 test: fix timezone issues in EventDisplay tests
- Set explicit UTC timezone globally in jest.config.ts and setupTests.ts
- Mock Intl.DateTimeFormat to use UTC by default while preserving prototype
- Replace regex patterns with exact values for declarative assertions
- Remove complex date formatting computations in tests
- Use fixed dates (2025-01-15T10:00:00.000Z) for consistent test results
- Fix EventDisplay.test.tsx to use exact time values instead of regex
2025-10-15 08:29:28 +02:00

68 lines
1.8 KiB
TypeScript

import type { Config } from "jest";
// Set timezone to UTC for consistent test results across all environments
process.env.TZ = "UTC";
const config: Config = {
collectCoverage: true,
coverageDirectory: "coverage",
projects: [
{
displayName: "dom",
clearMocks: true,
moduleFileExtensions: [
"js",
"mjs",
"cjs",
"jsx",
"ts",
"tsx",
"json",
"node",
],
testEnvironment: "jsdom",
testMatch: ["**/*.test.tsx"],
transform: {
"^.+\\.tsx?$": ["ts-jest", { tsconfig: "tsconfig.json" }],
"^.+\\.(js|jsx|mjs)$": "babel-jest",
"^.+\\.(css|scss|sass|less)$": "jest-preview/transforms/css",
"^(?!.*\\.(js|jsx|mjs|cjs|ts|tsx|css|json)$)":
"jest-preview/transforms/file",
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$":
"<rootDir>/fileTransformer.ts",
},
transformIgnorePatterns: [
"/node_modules/(?!(preact|@fullcalendar|react-calendar|get-user-locale|memoize|mimic-function|@wojtekmaj|ky)/)",
],
moduleNameMapper: { "^preact(/(.*)|$)": "preact$1" },
setupFilesAfterEnv: ["<rootDir>/src/setupTests.ts"],
},
{
displayName: "node",
clearMocks: true,
moduleFileExtensions: [
"js",
"mjs",
"cjs",
"jsx",
"ts",
"tsx",
"json",
"node",
],
testEnvironment: "node",
testMatch: ["**/*.test.ts"],
transform: {
"^.+\\.tsx?$": ["ts-jest", { tsconfig: "tsconfig.json" }],
"^.+\\.(js|jsx|mjs)$": "babel-jest",
},
transformIgnorePatterns: ["/node_modules/(?!(ky)/)"],
setupFilesAfterEnv: ["<rootDir>/src/setupTests.ts"],
},
],
};
export default config;