-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathjest.config.js
More file actions
63 lines (57 loc) · 1.91 KB
/
jest.config.js
File metadata and controls
63 lines (57 loc) · 1.91 KB
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
const { readdirSync } = require('fs');
const { resolve } = require('path');
const baseConfig = require('./jest/jest-base.config.js');
const makeDefaultConfig = require('./jest/make-default-config');
const packagesDir = resolve(__dirname, 'packages');
const appsDir = resolve(__dirname, 'apps');
const packages = readdirSync(packagesDir);
const apps = readdirSync(appsDir);
const appsWithCustomConfig = [];
const appsWithDefaultConfig = [];
apps.forEach((app) => {
const appDir = resolve(appsDir, app);
if (readdirSync(appDir).includes('jest.config.js')) {
appsWithCustomConfig.push(app);
} else {
appsWithDefaultConfig.push(app);
}
});
const packagesWithCustomConfig = [];
const packagesWithDefaultConfig = [];
packages.forEach((app) => {
const appDir = resolve(packagesDir, app);
if (readdirSync(appDir).includes('jest.config.js')) {
packagesWithCustomConfig.push(app);
} else {
packagesWithDefaultConfig.push(app);
}
});
const packageTestConfigs = packagesWithDefaultConfig.map((package) =>
makeDefaultConfig(packagesDir, package),
);
const appTestConfigs = appsWithDefaultConfig.map((app) =>
makeDefaultConfig(appsDir, app),
);
// For apps with a custom config in their directory, we just have to give Jest the path to them
const appPaths = appsWithCustomConfig.map((app) => resolve(appsDir, app));
const packagePaths = packagesWithCustomConfig.map((package) =>
resolve(packagesDir, package),
);
module.exports = {
...baseConfig,
projects: [
...packageTestConfigs,
...appTestConfigs,
...appPaths,
...packagePaths,
],
testTimeout: 10000,
testRegex: '^$', // root project does not have tests itself
watchPlugins: [
require.resolve('jest-watch-select-projects'),
require.resolve('jest-watch-typeahead/filename'),
require.resolve('jest-watch-typeahead/testname'),
require.resolve('jest-watch-suspend'),
require.resolve('jest-runner-eslint/watch-fix'),
],
};