Repository navigation
Expand file tree
/
Copy pathjest.config.js
More file actions
82 lines (78 loc) · 2.81 KB
/
Copy pathjest.config.js
File metadata and controls
82 lines (78 loc) · 2.81 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
/** @type {import('jest').Config} */
// The single definition of the coverage gate. It is enforced on the *merged*
// shard report by scripts/ci/coverage-merge.mjs, not by individual shard runs
// (issue #486), which pass --coverageThreshold '{}' because a shard only ever
// executes part of the suite.
module.exports = {
preset: "ts-jest",
testEnvironment: "node",
rootDir: "src",
testRegex: ".*\\.spec\\.ts$",
collectCoverageFrom: ["**/*.(t|j)s"],
coverageDirectory: "../coverage",
// text-summary keeps local runs readable, lcov feeds editors, and json is what
// coverage-merge.mjs consumes.
coverageReporters: ["text-summary", "lcov", "json"],
// Run both the main NestJS unit suite and the scripts suite under one command.
projects: [
// ── Main NestJS unit suite ──────────────────────────────────────────────
{
displayName: "src",
preset: "ts-jest",
testEnvironment: "node",
rootDir: "src",
testRegex: ".*\\.spec\\.ts$",
// Exclude the scripts sub-suite so tests aren't picked up twice.
testPathIgnorePatterns: ["/scripts/"],
collectCoverageFrom: ["**/*.(t|j)s"],
moduleNameMapper: {
"^@nestjs/schedule$": "<rootDir>/../test/__mocks__/nestjs-schedule.ts",
"^@nestjs/event-emitter$": "<rootDir>/../test/__mocks__/nestjs-event-emitter.ts",
},
},
// ── Scripts suite (ledger-utils, etc.) ─────────────────────────────────
// Tests live in src/scripts/ but import from scripts/ (outside src/).
// A dedicated tsconfig with broader rootDir handles the path.
{
displayName: "scripts",
testEnvironment: "node",
rootDir: ".",
testMatch: ["<rootDir>/src/scripts/**/*.spec.ts"],
transform: {
"^.+\\.tsx?$": [
"ts-jest",
{
tsconfig: "./tsconfig.scripts.json",
},
],
},
},
// ── Simulator tooling suite (issue #452) ───────────────────────────────
// The replay harness lives in tools/simulator/ (outside src/); same
// broader-rootDir trick as the scripts suite.
{
displayName: "tools",
testEnvironment: "node",
rootDir: ".",
testMatch: ["<rootDir>/tools/**/*.spec.ts"],
transform: {
"^.+\\.tsx?$": [
"ts-jest",
{
tsconfig: "./tsconfig.tools.json",
},
],
},
},
],
// Coverage is collected from the project-level collectCoverageFrom above.
coverageDirectory: "coverage",
coverageThreshold: {
global: {
branches: 70,
functions: 70,
lines: 70,
statements: 70,
},
},
};