-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.config.cjs
More file actions
137 lines (123 loc) · 3.45 KB
/
jest.config.cjs
File metadata and controls
137 lines (123 loc) · 3.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
module.exports = {
// Use projects for different test environments
projects: [
// Frontend tests (jsdom environment)
{
displayName: "frontend",
testEnvironment: "jsdom",
testMatch: ["<rootDir>/tests/frontend/**/*.test.{js,ts}"],
setupFilesAfterEnv: ["<rootDir>/tests/config/test-setup.js"],
moduleFileExtensions: ["js", "ts", "svelte", "json"],
transform: {
"^.+\\.js$": "babel-jest",
"^.+\\.ts$": "ts-jest",
"^.+\\.svelte$": [
"svelte-jester",
{
preprocess: true,
},
],
},
moduleNameMapper: {
"\\.(css|less|scss|sass)$": "identity-obj-proxy",
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$":
"<rootDir>/tests/config/__mocks__/fileMock.js",
"^@/(.*)$": "<rootDir>/app/frontend/src/$1",
"^@tests/(.*)$": "<rootDir>/tests/$1",
},
collectCoverageFrom: [
"app/frontend/src/**/*.{js,ts,svelte}",
"!app/frontend/src/**/*.d.ts",
"!app/frontend/src/main.js",
"!**/__mocks__/**",
"!**/node_modules/**",
],
},
// Backend tests (node environment)
{
displayName: "backend",
testEnvironment: "node",
testMatch: ["<rootDir>/tests/backend/**/*.test.{js,ts}"],
setupFilesAfterEnv: ["<rootDir>/tests/config/test-setup-backend.js"],
moduleFileExtensions: ["js", "ts", "json"],
transform: {
"^.+\\.js$": "babel-jest",
"^.+\\.ts$": "ts-jest",
},
moduleNameMapper: {
"^@backend/(.*)$": "<rootDir>/app/backend/src/$1",
"^@tests/(.*)$": "<rootDir>/tests/$1",
},
collectCoverageFrom: [
"app/backend/src/**/*.{js,ts}",
"!app/backend/src/**/*.d.ts",
"!app/backend/src/index.ts",
"!**/__mocks__/**",
"!**/node_modules/**",
],
},
],
// Global configuration
collectCoverage: true,
coverageDirectory: "<rootDir>/tests/coverage",
coverageReporters: ["text", "lcov", "html", "json-summary"],
// Note: Coverage patterns moved to individual projects to avoid cross-contamination
// Coverage thresholds (relaxed for initial implementation)
coverageThreshold: {
global: {
branches: 0,
functions: 0,
lines: 0,
statements: 0,
},
},
// Test timeout
testTimeout: 10000,
// Verbose output
verbose: true,
// Clear mocks between tests
clearMocks: true,
// Restore mocks after each test
restoreMocks: true,
// Error on deprecated features
errorOnDeprecated: true,
// Globals
globals: {
"ts-jest": {
useESM: true,
tsconfig: {
target: "es2022",
module: "esnext",
moduleResolution: "node",
allowSyntheticDefaultImports: true,
esModuleInterop: true,
},
},
},
// ESM support
extensionsToTreatAsEsm: [".ts"],
// Watch plugins
watchPlugins: [
"jest-watch-typeahead/filename",
"jest-watch-typeahead/testname",
],
// Reporters
reporters: [
"default",
[
"jest-junit",
{
outputDirectory: "<rootDir>/tests/reports",
outputName: "junit.xml",
classNameTemplate: "{classname}",
titleTemplate: "{title}",
ancestorSeparator: " › ",
usePathForSuiteName: true,
},
],
],
// Max workers for parallel execution
maxWorkers: "50%",
// Cache directory
cacheDirectory: "<rootDir>/node_modules/.cache/jest",
};