-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathjest.config.ts
More file actions
82 lines (72 loc) · 2.51 KB
/
jest.config.ts
File metadata and controls
82 lines (72 loc) · 2.51 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import type { Config } from 'jest';
const config: Config = {
projects: ['<rootDir>/jest.*.config.ts'],
verbose: true,
};
function modulesPattern(...args: string[]): string[] | undefined {
if (args.length === 0) {
return undefined;
}
return [`/node_modules/(?!(${args.join('|')}))`];
}
export const baseConfigFor = (project: string, testExtension: string): Config => ({
displayName: project,
roots: ['<rootDir>'],
moduleNameMapper: {
'^src(.*)$': '<rootDir>/src$1',
'^testsutil(/.+)?': '<rootDir>/testsutil$1',
'monaco-editor': '<rootDir>/__mocks__/monaco-editor.ts',
'package.json': '<rootDir>/__mocks__/packagejson.ts',
'^clipboard-polyfill': '<rootDir>/node_modules/@atlaskit/editor-common/dist/cjs/clipboard/index.js',
'prosemirror-model': '<rootDir>/node_modules/prosemirror-model', // alias to fix duplicate module issue
'prosemirror-view': '<rootDir>/node_modules/prosemirror-view', // alias to fix duplicate module issue
},
testMatch: [`**/*.test.${testExtension}`],
testPathIgnorePatterns: ['/node_modules/', '/e2e/'],
transform: {
'^.+\\.(js|ts|tsx)$': [
'ts-jest',
{
tsconfig: project === 'react' ? { esModuleInterop: true, isolatedModules: true } : false,
},
],
'^.+\\.(css|styl|less|sass|scss)$': 'jest-css-modules-transform',
},
transformIgnorePatterns: modulesPattern(
'@vscode/webview-ui-toolkit/',
'@microsoft/',
'exenv-es6/',
'@atlaskit/',
'flatten-anything/',
'filter-anything/',
'merge-anything',
'is-what/',
'axios-curlirize/',
'clipboard-polyfill/',
),
collectCoverage: true,
collectCoverageFrom: [
`src/**/*.${testExtension}`,
'!src/**/*.d.ts',
'!src/**/*.{spec,test}.{ts,tsx,js,jsx}', // Exclude test files
],
coverageDirectory: `coverage/${project}`,
coverageReporters: ['json', 'lcov', 'text-summary', 'clover', 'html'],
coverageThreshold: {
global:
testExtension === 'ts'
? {
statements: 65,
branches: 54,
functions: 59,
lines: 65,
}
: /* tsx */ {
statements: 14,
branches: 10,
functions: 10,
lines: 14,
},
},
});
export default config;