-
Notifications
You must be signed in to change notification settings - Fork 2
/
jest.config.js
67 lines (63 loc) · 1.81 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
64
65
66
67
const {
targets,
isComponent,
isTheme,
getShortName,
getPackageDir,
} = require('./scripts/utils')
const aliases = {
'\\.css$': '<rootDir>/test/unit/style.js',
'\\.scss$': '<rootDir>/test/unit/style.js',
'\\.png$': '<rootDir>/test/unit/image.js',
'\\.sprite\\.svg$': '<rootDir>/test/unit/svg.js',
}
let newTargets = targets
// console.log(process.env.IGNORE.split(','))
if (process.env.IGNORE) {
newTargets = targets.filter(
(target) => !process.env.IGNORE.split(',').includes(target)
)
}
newTargets.forEach((target) => {
const pkg = require(`${getPackageDir(target)}/package.json`)
aliases[`${target}$`] = `<rootDir>/${
isComponent(target) ? 'components' : isTheme(target) ? 'themes' : 'packages'
}/${getShortName(target)}/${/src/.test(pkg.main) ? pkg.main : 'src/index.ts'}`
})
module.exports = {
moduleNameMapper: aliases,
setupFilesAfterEnv: ['<rootDir>/test/unit/setup-jest.js'],
setupFiles: [
'<rootDir>/test/unit/setup-enzyme.js',
'<rootDir>/test/unit/setup-window.js',
],
transform: {
'^.+\\.tsx?$': 'ts-jest',
'^.+\\.jsx?$': 'babel-jest',
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'],
testPathIgnorePatterns: ['/node_modules/', '/old-packages/'],
transformIgnorePatterns: ['node_modules/(?!(lodash-es))/'],
collectCoverageFrom: [
'components/*/src/**/*.{ts,tsx}',
'packages/*/src/**/*.{ts,tsx}',
'!components/group/src/**/*.{ts,tsx}',
'!components/flex/src/**/*.{ts,tsx}',
],
snapshotSerializers: ['enzyme-to-json/serializer'],
coverageDirectory: 'coverage',
coverageThreshold: {
global: {
branches: 30,
functions: 30,
lines: 50,
statements: -3000,
},
},
globals: {
'ts-jest': {
tsConfig: '<rootDir>/tsconfig.test.json',
packageJson: '<rootDir>/package.json',
},
},
}