Repository navigation
Expand file tree
/
Copy pathjest.config.js
More file actions
82 lines (82 loc) · 4.63 KB
/
Copy pathjest.config.js
File metadata and controls
82 lines (82 loc) · 4.63 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
/**
* Jest configuration for the pure-TypeScript half of the SDK.
*
* Deliberately does NOT use `react-native`'s jest preset. Everything under
* test today (`utils/geometry`, `ocr/parsers/*`, `services/*Engine`,
* `services/AutoCaptureController`) is platform-free logic — it imports only
* `types/` and `constants/`, never `react-native` — so a plain `ts-jest`
* transform runs it in a fraction of the time and with none of the RN
* preset's Babel/Haste setup. Modules that DO touch the platform are stubbed
* via `moduleNameMapper` below so a future test can import a hook or screen
* without the whole RN toolchain.
*
* See docs/DEVELOPMENT.md.
*/
/** @type {import('jest').Config} */
module.exports = {
testEnvironment: 'node',
roots: ['<rootDir>/src', '<rootDir>/bench'],
testMatch: ['**/__tests__/**/*.test.ts', '**/__tests__/**/*.test.tsx'],
transform: {
'^.+\\.tsx?$': [
'ts-jest',
// `isolatedModules` lives in tsconfig.test.json, not here — the ts-jest
// option of that name is deprecated and removed in v30. Type errors are
// caught by `pnpm typecheck:tests`.
{ tsconfig: '<rootDir>/tsconfig.test.json' },
],
},
setupFilesAfterEnv: ['<rootDir>/jest.setup.ts'],
moduleNameMapper: {
'^react-native$': '<rootDir>/src/__mocks__/react-native.ts',
'^react-native-nitro-modules$': '<rootDir>/src/__mocks__/react-native-nitro-modules.ts',
'^react-native-vision-camera$': '<rootDir>/src/__mocks__/react-native-vision-camera.ts',
'^react-native-reanimated$': '<rootDir>/src/__mocks__/react-native-reanimated.ts',
'^react-native-mmkv$': '<rootDir>/src/__mocks__/react-native-mmkv.ts',
},
collectCoverageFrom: [
'src/**/*.ts',
'bench/**/*.ts',
'!src/**/__tests__/**',
'!src/**/__mocks__/**',
'!src/**/index.ts',
'!src/specs/**',
'!src/**/*.tsx',
],
coverageThreshold: {
// Per-file floors pinned at what M0 actually achieves. These are the real
// regression guards: they fail the build the moment a tested module loses
// coverage. Files with a path key here are excluded from the `global`
// bucket, so `global` measures only the still-untested remainder.
'./src/utils/geometry.ts': { statements: 100, branches: 100, functions: 100, lines: 100 },
'./src/services/GuidanceEngine.ts': { statements: 100, branches: 100, functions: 100, lines: 100 },
'./src/services/FaceGuidanceEngine.ts': { statements: 100, branches: 100, functions: 100, lines: 100 },
'./src/services/AutoCaptureController.ts': { statements: 100, branches: 100, functions: 100, lines: 100 },
'./src/ocr/parsers/mrzParser.ts': { statements: 95, branches: 74, functions: 100, lines: 97 },
// M6 decision engine. Held high on purpose: this is the component the
// capture experience lives or dies by, and it is pure logic with no device
// dependency, so there is no excuse for gaps.
'./src/decision/filters.ts': { statements: 98, branches: 90, functions: 100, lines: 100 },
'./src/decision/scoreFusion.ts': { statements: 100, branches: 95, functions: 100, lines: 100 },
'./src/decision/CaptureGate.ts': { statements: 97, branches: 84, functions: 100, lines: 100 },
'./src/decision/adaptiveThresholds.ts': { statements: 100, branches: 100, functions: 100, lines: 100 },
'./src/decision/DecisionEngine.ts': { statements: 96, branches: 85, functions: 100, lines: 98 },
// M7 capture decision layer.
'./src/capture/retryReasons.ts': { statements: 100, branches: 100, functions: 100, lines: 100 },
'./src/capture/StillVerifier.ts': { statements: 100, branches: 95, functions: 100, lines: 100 },
'./src/capture/BurstController.ts': { statements: 95, branches: 90, functions: 100, lines: 95 },
'./src/config/featureFlags.ts': { statements: 100, branches: 100, functions: 100, lines: 100 },
// M5 geometry. This is the reference implementation the Kotlin and Swift
// ports are held against, so gaps here are gaps in the oracle itself.
'./src/utils/quadGeometry.ts': { statements: 98, branches: 90, functions: 100, lines: 98 },
'./src/constants/documentAspects.ts': { statements: 100, branches: 95, functions: 100, lines: 100 },
'./src/vision/presenceGate.ts': { statements: 95, branches: 85, functions: 100, lines: 95 },
// A deliberately low ratchet over everything not yet under test (hooks,
// components, screens, stores, the native bridge mappers). Raise it in each
// milestone that adds coverage rather than lowering it to make CI pass —
// the roadmap's M1 adds the replay harness, M6 the decision engine.
global: { statements: 8, branches: 3, functions: 2, lines: 9 },
},
clearMocks: true,
restoreMocks: true,
};