-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathjest.config.cjs
More file actions
54 lines (48 loc) · 1.63 KB
/
jest.config.cjs
File metadata and controls
54 lines (48 loc) · 1.63 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
/* eslint-disable @typescript-eslint/no-require-imports */
const path = require('path');
/**
* Function that loads the target project config, deleting options not usable in the config
* @param {string} dir - Path to the subproject
*/
function loadProjectConfig(dir) {
/** @type { Exclude<import('jest').Config['projects'], undefined>[number] } */
const config = require(`./${dir}/jest.config.js`);
/** @type { Exclude<import('jest').Config['projects'], undefined>[number] } */
const resultConfig = {
...config,
displayName: dir,
rootDir: path.join('./', dir, config.rootDir ?? '.'),
};
// Fixup ts-jest project links
if (typeof resultConfig !== 'string' && resultConfig.transform) {
for (const transformConfig of Object.values(resultConfig.transform)) {
if (
typeof transformConfig !== 'string' &&
transformConfig[0] === 'ts-jest' &&
transformConfig[1] != null &&
typeof transformConfig[1] === 'object' &&
typeof transformConfig[1].tsconfig === 'string'
) {
transformConfig[1].tsconfig = path.resolve('./', dir, transformConfig[1].tsconfig);
}
}
}
delete resultConfig.collectCoverageFrom;
delete resultConfig.coverageDirectory;
delete resultConfig.coverageProvider;
return resultConfig;
}
/**
* For a detailed explanation regarding each configuration property and type check, visit:
* https://jestjs.io/docs/configuration
* @type { import('jest').Config }
*/
module.exports = {
projects: [
loadProjectConfig('pandora-common'),
loadProjectConfig('pandora-server-directory'),
loadProjectConfig('pandora-server-shard'),
loadProjectConfig('pandora-client-web'),
],
errorOnDeprecated: true,
};