-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathjest.config.base.ts
More file actions
44 lines (41 loc) · 1.31 KB
/
jest.config.base.ts
File metadata and controls
44 lines (41 loc) · 1.31 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
import type { Config } from 'jest';
import path from 'node:path';
const COVERAGE_PATH_IGNORE_PATTERNS = [
'<rootDir>/node_modules/',
'<rootDir>/dist/',
'/node_modules/',
'/dist/',
'packages/gamut-icons/dist/icons/',
'packages/gamut-patterns/dist/patterns/',
];
const baseConfig = (packageName: string, overrides: Config): Config => {
const outputDirectory = path.join(__dirname, `coverage/${packageName}`);
return {
displayName: packageName,
preset: '../../jest.preset.js',
clearMocks: true,
coverageDirectory: outputDirectory,
coverageReporters: process.env.CI
? ['clover', 'json', 'lcov', 'text']
: ['html', 'text'],
reporters: process.env.CI
? [
'default',
'github-actions',
['jest-junit', { addFileAttribute: true, outputDirectory }],
]
: ['default'],
moduleNameMapper: {
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|md)$':
'<rootDir>/../../script/jest/fileMock',
'\\.(css|scss)$': '<rootDir>/../../script/jest/styleMock',
},
testPathIgnorePatterns: ['node_modules', 'dist'],
...overrides,
coveragePathIgnorePatterns: [
...COVERAGE_PATH_IGNORE_PATTERNS,
...(overrides.coveragePathIgnorePatterns ?? []),
],
};
};
export default baseConfig;