-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathjest.config.js
More file actions
70 lines (61 loc) · 3.43 KB
/
jest.config.js
File metadata and controls
70 lines (61 loc) · 3.43 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
module.exports = {
moduleFileExtensions: ['js', 'json', 'ts'],
rootDir: 'src',
testRegex: '.*\\.spec\\.ts$',
transform: {
'^.+\\.(t|j)s$': 'ts-jest',
},
// ─── Coverage ──────────────────────────────────────────────────────────────
// Collect from all source files (excludes test files and generated artifacts)
collectCoverageFrom: [
'**/*.(t|j)s',
'!**/*.spec.ts',
'!**/*.module.ts',
'!**/main.ts',
'!**/*.dto.ts',
'!**/*.entity.ts',
'!**/*.enum.ts',
'!**/*.interface.ts',
'!**/*.decorator.ts',
'!**/*.config.ts',
'!**/index.ts',
],
coverageDirectory: '../coverage',
// text — printed to stdout (CI logs)
// lcov — consumed by GitHub Actions coverage summary step
// html — uploaded as an artifact for visual inspection
coverageReporters: ['text', 'lcov', 'html', 'json-summary', 'cobertura'],
// ─── Coverage Thresholds ───────────────────────────────────────────────────
// Pipeline fails if any metric falls below these values.
// Adjust upward incrementally as the test suite matures.
coverageThreshold: {
global: {
branches: Number(process.env.COVERAGE_THRESHOLD_BRANCHES || 0),
functions: Number(process.env.COVERAGE_THRESHOLD_FUNCTIONS || 0),
lines: Number(process.env.COVERAGE_THRESHOLD_LINES || 0),
statements: Number(process.env.COVERAGE_THRESHOLD_STATEMENTS || 0),
},
},
// ─── Environment ───────────────────────────────────────────────────────────
testEnvironment: 'node',
// ─── Performance ───────────────────────────────────────────────────────────
// Run sequentially in CI to stay within GitHub-hosted runner memory limits.
// Locally, remove or increase maxWorkers for faster feedback.
maxWorkers: process.env.CI ? 1 : '50%',
workerIdleMemoryLimit: '512MB',
// ─── Timeouts ──────────────────────────────────────────────────────────────
testTimeout: 15000,
// ─── Setup ─────────────────────────────────────────────────────────────────
setupFilesAfterEnv: ['<rootDir>/../test/setup.ts'],
moduleNameMapper: {
'^uuid$': '<rootDir>/../test/mocks/uuid.ts',
},
// ─── Ignore patterns ───────────────────────────────────────────────────────
testPathIgnorePatterns: ['/node_modules/', '/dist/', '/coverage/'],
// ─── Output & lifecycle ────────────────────────────────────────────────────
verbose: true,
// forceExit prevents Jest from hanging on open handles (e.g. TypeORM pools)
forceExit: true,
clearMocks: true,
restoreMocks: true,
};