-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathjest.config.js
More file actions
113 lines (110 loc) · 4.95 KB
/
Copy pathjest.config.js
File metadata and controls
113 lines (110 loc) · 4.95 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/**
* Two project setup:
* - unit: existing tests for services + stores. Mocks react-native to an
* empty module so we can run pure-logic tests without the RN runtime.
* - components: tests for `<Component>` files. Uses the jest-expo preset
* so React Native primitives (Text, Pressable, View, ActivityIndicator)
* render through @testing-library/react-native.
*/
const sharedTransform = {
'^.+\\.tsx?$': [
'babel-jest',
{
presets: [
['@babel/preset-env', { targets: { node: 'current' } }],
'@babel/preset-typescript',
['@babel/preset-react', { runtime: 'automatic' }],
],
},
],
};
const sharedNameMapper = {
'^@/(.*)$': '<rootDir>/src/$1',
'^@modules/(.*)$': '<rootDir>/modules/$1',
};
module.exports = {
// Coverage scope is the logic surface only: services + stores. Screens and
// feature UI are owned by component tests, visual regression and Maestro —
// forcing line coverage on JSX produces useless render tests, not safety.
// The floor is enforced by scripts/check-coverage-floor.mjs against the
// committed .coverage-floor-lines file (see that script for the ratchet
// protocol).
collectCoverageFrom: [
'src/services/**/*.{ts,tsx}',
'src/store/**/*.{ts,tsx}',
'src/features/**/services/**/*.{ts,tsx}',
'src/hooks/**/*.{ts,tsx}',
// Security-critical feature logic that lives outside a `services/` folder
// but must still be measured (and is pinned in .coverage-floors.json).
'src/features/biometric/biometric.ts',
// Portfolio logic + screens (full-area coverage).
'src/features/portfolio/useTotalPortfolioFiatFull.ts',
'src/features/portfolio/useEnabledChains.ts',
'src/features/portfolio/PortfolioScreenImpl.tsx',
'src/features/portfolio/PortfolioAssetDetailScreenImpl.tsx',
'src/features/portfolio/PortfolioManageScreenImpl.tsx',
// Settings logic + screens (full-area coverage).
'src/features/settings/SettingsScreenImpl.tsx',
'src/features/settings/SeedExportScreenImpl.tsx',
// Multi-Sig logic + screens (full-area coverage).
'src/features/multi-sig/store.ts',
'src/features/multi-sig/MultiSigSetupScreenImpl.tsx',
'src/features/multi-sig/MultiSigManageScreenImpl.tsx',
'!**/*.d.ts',
'!**/types.ts',
],
coverageReporters: ['json-summary', 'lcov', 'text-summary'],
projects: [
{
displayName: 'unit',
transform: sharedTransform,
setupFiles: ['<rootDir>/test/setup-globals.ts'],
testMatch: [
'<rootDir>/test/services/**/*.test.ts',
'<rootDir>/test/store/**/*.test.ts',
],
moduleNameMapper: {
...sharedNameMapper,
'^react-native-mmkv$': '<rootDir>/test/__mocks__/react-native-mmkv.ts',
'^react-native$': '<rootDir>/test/__mocks__/empty.ts',
'^react-native-nitro-modules$': '<rootDir>/test/__mocks__/empty.ts',
'^react-native-ble-plx$': '<rootDir>/test/__mocks__/empty.ts',
'^expo-secure-store$': '<rootDir>/test/__mocks__/expo-secure-store.ts',
'^expo-crypto$': '<rootDir>/test/__mocks__/expo-crypto.ts',
'^expo-local-authentication$': '<rootDir>/test/__mocks__/expo-local-authentication.ts',
'^expo-haptics$': '<rootDir>/test/__mocks__/empty.ts',
'^expo-clipboard$': '<rootDir>/test/__mocks__/empty.ts',
'^expo-camera$': '<rootDir>/test/__mocks__/empty.ts',
'^expo-localization$': '<rootDir>/test/__mocks__/empty.ts',
'^react-native-qrcode-svg$': '<rootDir>/test/__mocks__/empty.ts',
'^@tetherto/wdk-react-native-core$': '<rootDir>/test/__mocks__/wdk.ts',
'^@tetherto/wdk-pricing-bitfinex-http$': '<rootDir>/test/__mocks__/empty.ts',
'^@tetherto/wdk-pricing-provider$': '<rootDir>/test/__mocks__/empty.ts',
'^bitbox-api$': '<rootDir>/test/__mocks__/empty.ts',
},
},
{
displayName: 'components',
preset: 'jest-expo',
transform: sharedTransform,
testMatch: ['<rootDir>/test/components/**/*.test.tsx'],
// Same global flag setup as the unit project: pin every
// EXPO_PUBLIC_ENABLE_* to "true" before any feature wrapper loads,
// so `FEATURES.X` resolves to the real implementation in the
// components project's screen tests as well.
setupFiles: ['<rootDir>/test/setup-globals.ts'],
moduleNameMapper: {
...sharedNameMapper,
// The WDK package ships TypeScript source on npm and Jest's transform
// chain does not handle `export type {…}` inside node_modules without
// help. The local mock under `test/__mocks__/wdk.ts` exposes the
// surface our hooks touch (BaseAsset, useAccount, useRefreshBalance,
// …) without dragging in the Bare worklet.
'^@tetherto/wdk-react-native-core$': '<rootDir>/test/__mocks__/wdk.ts',
},
// jest-expo's defaults already cover react-native; add overrides for
// wallet-specific dependencies that should not run their native bridge
// during a pure component render test.
},
],
};