-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
jest.config.js
57 lines (54 loc) · 2.01 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
const Fs = require('fs');
const Path = require('path');
const pkg = require('./package.json');
const workspaces = [];
const packages = Array.isArray(pkg.workspaces) ? pkg.workspaces : pkg.workspaces.packages ?? [];
for (const packageGlob of packages) {
if (packageGlob.startsWith('../')) continue;
let workspacePath = packageGlob;
// if we're not in build already, need to add build
if (!__dirname.includes('build') && !workspacePath.includes('build')) {
workspacePath = `build/${workspacePath}`;
}
if (workspacePath.endsWith('/*')) {
workspacePath = workspacePath.replace('/*', '');
for (const subdir of Fs.readdirSync(Path.resolve(__dirname, workspacePath))) {
if (subdir === 'node_modules') continue;
if (!Fs.statSync(Path.resolve(__dirname, workspacePath, subdir)).isDirectory()) continue;
if (!Fs.existsSync(Path.resolve(__dirname, workspacePath, subdir, 'package.json'))) continue;
workspaces.push(`${workspacePath}/${subdir}`);
}
} else {
workspaces.push(workspacePath);
}
}
module.exports = {
verbose: false,
testMatch: ['**/test/*.test.js'],
testEnvironment: 'node',
collectCoverage: false,
transform: {},
collectCoverageFrom: workspaces.map(x => `${x}/**/*.js`),
coverageReporters: ['text-summary', 'json'],
coveragePathIgnorePatterns: [
'node_modules',
'<rootDir>/testing/*',
'<rootDir>/.*/interfaces/*',
'<rootDir>/.*/interfaces/*.[ts|js]',
'<rootDir>/.*/bin/*.[ts|js]',
'<rootDir>/.*/start.[ts|js]',
'<rootDir>/.*/install.[ts|js]',
'<rootDir>/.*/install/*.[ts|js]',
'<rootDir>/.*/server.[ts|js]',
'<rootDir>/.*/test/.*.js',
'<rootDir>/.*.d.ts',
'<rootDir>/.*.json',
],
globalTeardown: './jest.teardown.js',
globalSetup: './jest.setup.js',
setupFilesAfterEnv: ['./jest.setupPerTest.js'],
testTimeout: 15e3,
reporters: ['default', ['github-actions', { silent: false }], 'summary'],
roots: workspaces.map(x => `${x}/`),
moduleDirectories: ['node_modules', ...workspaces.map(x => `${x}/node_modules`)],
};