forked from KnodesCommunity/typedoc-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjest.config.js
50 lines (47 loc) · 1.43 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
const { existsSync } = require( 'fs' );
const { resolve } = require( 'path' );
const { isString } = require( 'lodash' );
const { anyExt } = require( './jest.config.base' );
const { getProjects } = require( './tools/utils' );
const projects = getProjects();
const maxNameLength = Math.max( ...projects.map( p => p.name.length ) );
module.exports = {
collectCoverageFrom: [
'**/src/**',
`!**/index${anyExt}`,
'!**/__tests__/**',
`!**/*.spec${anyExt}`,
],
// ...baseConfig,
projects: projects
.map( ( { path, ...other } ) => {
const jestConfigPath = [ 'jest.workspace.config.js', 'jest.config.js' ]
.map( c => resolve( path, c ) )
.find( existsSync );
return { ...other, path, jestConfigPath };
} )
.filter( ( { jestConfigPath } ) => isString( jestConfigPath ) )
.map( ( { jestConfigPath, path, name } ) => {
const config = require( jestConfigPath );
if( config.projects ){
return config.projects.map( pp => ( { name, jestConfig: { ...pp, rootDir: path }} ) );
} else {
return { name, jestConfig: { ...config, rootDir: path }};
}
} )
.flat( 1 )
.map( ( { jestConfig, name } ) => {
if( jestConfig.displayName ){
const sep = `${' '.repeat( maxNameLength - name.length )} ⇒ `;
jestConfig.displayName = {
...jestConfig.displayName,
name: `${name}${sep}${jestConfig.displayName.name}`,
};
} else {
jestConfig.displayName = {
name,
};
}
return jestConfig;
} ),
};