-
Notifications
You must be signed in to change notification settings - Fork 306
/
jest.config.js
39 lines (29 loc) · 971 Bytes
/
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
const path = require('path');
const fs = require('fs');
const ROOT_DIR = __dirname;
module.exports = {
projects: getJestProjects(),
testPathIgnorePatterns: ['<rootDir>/packages/'],
modulePathIgnorePatterns: ['fixture'],
reporters: ['default', require.resolve('jest-junit')],
};
function getJestProjects() {
const packagePaths = ['packages/common', 'packages/react'].flatMap(dir => {
const parent = path.resolve(ROOT_DIR, dir);
const dirs = fs.readdirSync(parent);
return dirs.map(d => path.join(parent, d));
});
return packagePaths.flatMap(packagePath => {
const packageJestConfig = path.resolve(packagePath, 'jest.config.js');
if (!fs.existsSync(packageJestConfig)) {
return [];
}
const config = require(packageJestConfig);
if (config.projects) {
return config.projects.map(project => {
return project.replace(/<rootDir>/g, packagePath);
});
}
return [packageJestConfig];
});
}