-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathjest.config.js
More file actions
67 lines (64 loc) · 1.8 KB
/
Copy pathjest.config.js
File metadata and controls
67 lines (64 loc) · 1.8 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
const { createDefaultPreset } = require('ts-jest');
const tsJestTransformCfg = createDefaultPreset().transform;
/** @type {import("jest").Config} **/
module.exports = {
testEnvironment: 'node',
transform: {
...tsJestTransformCfg,
'^.+\\.tsx?$': [
'ts-jest',
{
...tsJestTransformCfg['^.+\\.tsx?$'][1],
isolatedModules: true,
},
],
},
setupFiles: ['<rootDir>/tests/jest.setup.ts'],
// Allow enough time for MongoMemoryServer to start (and download the binary
// on first run in a fresh environment).
testTimeout: 30000,
// Exclude the compiled output directory — tests should only run from source.
testPathIgnorePatterns: ['/node_modules/', '/dist/'],
// Coverage configuration for test enforcement
collectCoverageFrom: [
'src/**/*.ts',
'!src/**/*.d.ts',
'!src/**/index.ts',
'!src/server.ts',
'!src/seed.ts',
],
coverageDirectory: 'coverage',
coverageReporters: ['text', 'lcov', 'json-summary'],
// Global coverage thresholds (80% bar across all code)
// Services layer is held to 80% as core business logic
// Controllers/Routes/Utils may have lower thresholds initially
coverageThreshold: {
global: {
branches: 60,
functions: 60,
lines: 60,
statements: 60,
},
// Services are the core business logic layer — enforce 80% coverage
'./src/services/': {
branches: 80,
functions: 80,
lines: 80,
statements: 80,
},
// Models represent data contracts — enforce 75% coverage
'./src/models/': {
branches: 70,
functions: 70,
lines: 70,
statements: 70,
},
// Routes handle HTTP contracts — enforce 70% coverage
'./src/routes/': {
branches: 60,
functions: 60,
lines: 60,
statements: 60,
},
},
};