forked from MentorsMind/MentorsMind-Backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.integration.config.ts
More file actions
73 lines (61 loc) · 2.05 KB
/
Copy pathjest.integration.config.ts
File metadata and controls
73 lines (61 loc) · 2.05 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
import type { Config } from "jest";
/**
* Jest configuration for integration tests.
*
* - Matches files ending in *.integration.test.ts anywhere under src/
* - Spins up real PostgreSQL and Redis via testcontainers (globalSetup)
* - Runs --runInBand so containers are shared and tests are sequential
* - Resets DB and Redis before every test (integrationSetup.ts)
*/
const config: Config = {
preset: "ts-jest",
testEnvironment: "node",
rootDir: ".",
roots: ["<rootDir>/src"],
// Only pick up integration test files
testMatch: ["**/*.integration.test.ts"],
// One-time container lifecycle wired to the main Jest process
globalSetup: "<rootDir>/src/__tests__/setup/globalSetup.ts",
globalTeardown: "<rootDir>/src/__tests__/setup/globalTeardown.ts",
// Per-file setup: truncate DB + flush Redis before each test
setupFilesAfterEnv: ["<rootDir>/src/__tests__/setup/integrationSetup.ts"],
// TypeScript compilation via ts-jest
transform: {
"^.+\\.ts$": [
"ts-jest",
{
tsconfig: {
target: "ES2022",
module: "commonjs",
lib: ["ES2022"],
strict: false,
esModuleInterop: true,
skipLibCheck: true,
forceConsistentCasingInFileNames: true,
resolveJsonModule: true,
allowSyntheticDefaultImports: true,
},
diagnostics: false,
},
],
},
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"],
moduleNameMapper: {
"^@/(.*)$": "<rootDir>/src/$1",
// uuid mock used by unit tests is NOT needed here – skip it so integration
// tests get real UUIDs from the database.
},
// Must run serially: containers are shared across files
// (pass --runInBand on the CLI as well)
maxWorkers: 1,
// Integration tests are slower – give them more time
testTimeout: 60_000,
clearMocks: true,
restoreMocks: true,
// Keep module cache across files so the pg Pool and Redis client persist
resetModules: false,
verbose: true,
forceExit: true,
detectOpenHandles: true,
};
export default config;