-
Notifications
You must be signed in to change notification settings - Fork 55
/
config-overrides.js
91 lines (78 loc) · 2.96 KB
/
config-overrides.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
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
const { assign } = require('lodash')
const dotenv = require('dotenv')
const { existsSync } = require('fs')
module.exports = {
webpack: (conf, env) => {
const configType = env === 'production' ? 'prod' : 'dev'
const webpackConfig = require(`./config/webpack.config.${configType}`)
const config = assign(conf, webpackConfig)
if (configType === 'dev') {
config.resolve.alias['react-dom'] = '@hot-loader/react-dom'
}
return config
},
jest: config => {
// some shells like zsh + oh-my-zsh plugins set
// are preloading .env file to the shell env
// so dotenv won't update those vars (already existing)
// latest dotenv versions have override option
// for now we will just clean up process.env from react_app vars
// then re-setup dotenv with .env.test
// TODO: update dotenv
if (existsSync('./.env')) {
Object
.keys(process.env)
.filter(key => key.startsWith('REACT_APP'))
.forEach(key => delete process.env[key])
dotenv.config({ path: './.env.test' })
}
config.transformIgnorePatterns = [
'<rootDir>/node_modules/@gooddollar/react-native-facetec/web/sdk',
'<rootDir>/node_modules/(?!(jest-)?react-native|react-navigation|react-navigation-redux-helpers|react-phone-number-input|webrtc-adapter|@gooddollar/react-native-facetec|@ceramicnetwork|@web3-onboard|axios)',
]
config.setupFiles = [
'react-app-polyfill/jsdom',
'<rootDir>/config/initTest.js',
]
config.globals = {
TZ: 'UTC',
}
config.testPathIgnorePatterns = [
'/__tests__/__util__/',
'/__tests__/__suites__/',
'/__tests__/__mocks__/',
'<rootDir>/src/index.js',
'<rootDir>/src/init.js',
'<rootDir>/src/serviceWorker.js',
]
config.coveragePathIgnorePatterns = [
"/__tests__/__util__/",
"/__tests__/__suites__/",
"<rootDir>/src/index.js",
"<rootDir>/src/init.js",
"<rootDir>/src/serviceWorker.js",
"<rootDir>/node_modules/@gooddollar/react-native-facetec/web/sdk"
]
config.moduleNameMapper = {
...config.moduleNameMapper,
'\\.(css|less)$': '<rootDir>/src/__tests__/__mocks__/styleMock.js',
'lottie-react-native': 'react-native-web-lottie',
}
if (process.env.TEST_REACT_NATIVE === 'true') {
config.coverageDirectory = 'coverageNative'
config.preset = 'react-native'
config.testPathIgnorePatterns.push('<rootDir>/src/.*/.*(web).js')
config.coveragePathIgnorePatterns.push('<rootDir>/src/.*/.*(web).js')
} else {
config.moduleNameMapper = {
...config.moduleNameMapper,
'^react-native-linear-gradient$': 'react-native-web-linear-gradient',
}
config.resolver = 'jest-pnp-resolver'
config.testURL = 'http://localhost'
config.testPathIgnorePatterns.push('<rootDir>/src/.*/.*(android|ios|native).js')
config.coveragePathIgnorePatterns.push('<rootDir>/src/.*/.*(android|ios|native).js')
}
return config
},
}