Repository navigation
Expand file tree
/
Copy pathjest.config.js
More file actions
41 lines (39 loc) 路 1.95 KB
/
Copy pathjest.config.js
File metadata and controls
41 lines (39 loc) 路 1.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
module.exports = {
maxConcurrency: 10,
preset: '@react-native/jest-preset',
// This is a large departure from most react-native jest testing
// they use a variant of 'jsdom' (tailored for react-native) so they
// load web bundles etc.
//
// This is a problem during the CJS / ESM transition though - firebase
// creates a web bundle that uses ESM modules now and defines standard
// entry points for web bundle loaders to use them. So jest tries to load
// the ESM bundle and Jest / ts-jest attempt to transform / use them, but
// they don't support ESM well.
//
// So we just brutally alter the test environment to 'node'. No web testing
// is possible, but that's okay for us, and it loads the non-ESM bundle now.
testEnvironment: 'node',
transform: {
'^.+\\.(js)$': '<rootDir>/node_modules/babel-jest',
'\\.(ts|tsx)$': ['ts-jest', { tsconfig: './tsconfig-jest.json' }],
},
setupFiles: ['./jest.setup.ts'],
globalSetup: './scripts/jest-ai-mocks-global-setup.js',
testMatch: ['**/packages/**/__tests__/**/*.test.(ts|js)'],
modulePaths: ['node_modules', './tests/node_modules'],
testPathIgnorePatterns: ['./packages/template'],
moduleDirectories: ['node_modules', './tests/node_modules'],
moduleFileExtensions: ['ts', 'tsx', 'js', 'mjs'],
transformIgnorePatterns: [
'node_modules/(?!((jest-)?react-native|@firebase|@react-native(-community)?))',
],
// Packages cross-import each other's built output (e.g. database imports
// `@react-native-firebase/app/dist/module/common/deeps`), which resolves
// through the workspace symlink to `packages/*/dist/**`. Without this,
// Jest instruments both that build artifact and the original `lib/**.ts`
// source it was compiled from, so any shared file with branches gets a
// second, all-zero coverage entry alongside the real one, and codecov's
// patch coverage misreports lines that are actually fully tested.
coveragePathIgnorePatterns: ['/node_modules/', '/dist/'],
};