-
-
Notifications
You must be signed in to change notification settings - Fork 298
/
jest.config.js
58 lines (52 loc) · 1.8 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
const fs = require('fs');
const path = require('path');
const packages = fs
.readdirSync(path.join(process.cwd(), 'packages'))
.filter((name) => !['dev-utils', 'codemod'].includes(name));
const roots = packages.map((name) => `<rootDir>/packages/${name}/src`);
roots.push('<rootDir>/packages/codemod');
const docsSrc = '<rootDir>/packages/documentation/src';
const isWatchMode = /(-w|--watch)(\s?.+)?$/.test(process.argv);
let collectCoverageFrom = [];
if (!isWatchMode) {
collectCoverageFrom = [
'<rootDir>/packages/*/src/**/*.{ts,tsx}',
// internal usage and don't matter for the library coverage reports
'!<rootDir>/packages/{dev-utils,documentation,material-icons,react-md}/src/**/*',
'!<rootDir>/packages/codemod/**/*',
// these are generated files
'!<rootDir>/packages/*/src/scssVariables.ts',
// index.ts files are always `export * from "./fileOrFolder"`
'!<rootDir>/packages/**/index.ts',
];
}
module.exports = {
preset: 'ts-jest',
testEnvironment: 'jsdom',
roots,
globals: {
'ts-jest': {
tsconfig: './tsconfig.test.json',
},
},
setupFilesAfterEnv: ['<rootDir>/testSetup/init.js'],
transform: {
'\\.svg$': '<rootDir>/testSetup/inlineSvgTransformer.js',
'\\.(jpg|jpeg|png|gif|eot|otf|webp|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
'<rootDir>/testSetup/fileTransformer.js',
},
moduleNameMapper: {
'\\.scss$': 'identity-obj-proxy',
'^constants/(.*)$': `${docsSrc}/constants/$1`,
'^components/(.*)$': `${docsSrc}/components/$1`,
'^hooks/(.*)$': `${docsSrc}/hooks/$1`,
'^icons/(.*)$': `${docsSrc}/icons/$1`,
'^pages/(.*)$': `${docsSrc}/pages/$1`,
'^utils/(.*)$': `${docsSrc}/utils/$1`,
},
collectCoverageFrom,
watchPlugins: [
'jest-watch-typeahead/filename',
'jest-watch-typeahead/testname',
],
};