-
Notifications
You must be signed in to change notification settings - Fork 4
/
jest.config.mjs
35 lines (33 loc) · 1.08 KB
/
jest.config.mjs
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
import { resolve } from 'path';
import { pathToFileURL } from 'url';
import { getProjects } from './tools/utils.mjs';
const projects = getProjects();
const maxNameLength = Math.max( ...projects.map( p => p.name.length ) );
const projectsConfigs = await Promise.all( projects
.map( ( { path, ...other } ) => ( { ...other, path, jestConfigPath: pathToFileURL( resolve( path, 'jest.config.mjs' ) ) } ) )
.map( async ( { jestConfigPath, name } ) => {
const { default: config } = await import( jestConfigPath );
if( config.projects ){
return config.projects.map( pp => ( { name, jestConfig: { ...pp }} ) );
} else {
return { name, jestConfig: { ...config }};
}
} ) );
export default {
projects: projectsConfigs
.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;
} ),
};