This repository has been archived by the owner on Jan 28, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjest.config.js
53 lines (48 loc) · 1.72 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
// @ts-check
/**
* 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
*/
// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require('path');
const packagesToTransform = [
'react-native',
'react-native-(.*)',
'@react-native',
'@react-native-community',
'@react-native-tvos',
'@react-navigation',
];
/** @type {import('@jest/types').Config.InitialOptions} */
const config = {
preset: '@testing-library/react-native',
/*
* What the preset provides:
* - a transformer to handle media assets (png, video)
*/
// test environment setup
setupFiles: ['./src/testing/jest-setup.ts'],
setupFilesAfterEnv: ['./src/testing/jest-setupAfterEnv.ts'],
clearMocks: true,
// module resolution
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
testRegex: '\\.test\\.[jt]sx?$',
transform: {
'\\.[jt]sx?$': [
'babel-jest',
{ configFile: path.resolve(__dirname, './babel.jest.config.js') },
],
},
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
};
module.exports = config;