-
Notifications
You must be signed in to change notification settings - Fork 1
/
jest.config.js
63 lines (61 loc) · 2.15 KB
/
jest.config.js
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
/**
* Code in the react-native ecosystem if often shipped untransformed, with flow or typescript in files
* App code also needs to be transformed (it's TypeScript), but the rest of node_modules doesn't need to
* Transforming the minimum amount of code makes tests run much faster
*
* If encountering a syntax error during tests with a new package, add it to this list
*/
const packagesToTransform = [
'react-native',
'react-native-(.*)',
'@react-native',
'@react-native-community',
'@react-navigation',
'expo',
'expo-(.*)',
];
/** @type {import('@jest/types').Config.InitialOptions} */
const config = {
/*
* What the preset provides:
* - a transformer to handle media assets (png, video)
* - lots of mocks for react-native and expo modules
*/
preset: 'jest-expo',
// test environment setup
globalSetup: '<rootDir>/src/testing/jest-globalSetup.ts',
setupFiles: ['./src/testing/jest-setup.js'],
setupFilesAfterEnv: ['./src/testing/jest-setupAfterEnv.js'],
clearMocks: true,
// module resolution
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
moduleNameMapper: {
// Keep in sync with babel.config.js and tsconfig.json
'#app/(.*)': '<rootDir>/src/app/$1',
'#modules/(.*)': '<rootDir>/src/modules/$1',
'#shared/(.*)': '<rootDir>/src/shared/$1',
'#testing/(.*)': '<rootDir>/src/testing/$1',
},
modulePaths: ['<rootDir>'],
testRegex: '\\.test\\.[jt]sx?$',
// module transformation
transform: {
// NOTE: If your projects uses special babel plugins, you'll need to go back to the slower default babel-jest setup
'^.+\\.(js)$': '<rootDir>/node_modules/babel-jest',
},
transformIgnorePatterns: [
`node_modules/(?!(${packagesToTransform.join('|')})/)`,
],
cacheDirectory: '.cache/jest',
// coverage
collectCoverageFrom: ['src/**/*.{js,jsx,ts,tsx}'],
coveragePathIgnorePatterns: ['/node_modules/'],
// tools
watchPlugins: [
'jest-watch-typeahead/filename',
'jest-watch-typeahead/testname',
],
reporters: ['default', 'github-actions'], // Remove this line if your CI is not on Github actions
snapshotResolver: './jestSnapshotResolver.js',
};
module.exports = config;