-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjest.config.js
45 lines (41 loc) · 1.31 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
const aliases = require('./config/aliases')
const path = require('path')
const appDirectory = fs.realpathSync(process.cwd())
// alias: 'root/dir/some/path' ===> 'alias(/.*)?': '<rootDir>/some/path$1',
const jestModulesMap = Object.entries(aliases).reduce((obj, [key, value]) => {
obj[`^${key}(.*)`] = `${value.replace(appDirectory, '<rootDir>')}$1`
return obj
}, {})
module.exports = {
'collectCoverageFrom': [
'source/client/**/*.{js,jsx,mjs}'
],
'setupTestFrameworkScriptFile': '<rootDir>config/setupTests.js',
'testMatch': [
path.resolve(appDirectory, 'source/client/**/__tests__/**/*.{js,jsx,mjs}'),
path.resolve(appDirectory, 'source/client/**/?(*.)(spec|test).{js,jsx,mjs}'),
],
'testEnvironment': 'jsdom',
'testURL': 'http://localhost',
'transform': {
'^.+\\.(js|jsx|mjs)$': path.resolve(appDirectory, 'node_modules/babel-jest'),
'^.+\\.css$': path.resolve(appDirectory, 'config/jest/cssTransform.js'),
'^(?!.*\\.(js|jsx|mjs|css|json)$)': path.resolve(appDirectory, 'config/jest/fileTransform.js'),
},
'transformIgnorePatterns': [
'[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs)$'
],
'moduleNameMapper': jestModulesMap,
'moduleFileExtensions': [
'web.js',
'mjs',
'js',
'json',
'web.jsx',
'jsx',
'node'
],
'globals': {
GLOBAL_CONFIG: {}
}
}