-
Notifications
You must be signed in to change notification settings - Fork 238
/
Copy pathjest.config.ts
59 lines (53 loc) · 1.56 KB
/
jest.config.ts
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
import { version as typescriptESLintPluginVersion } from '@typescript-eslint/eslint-plugin/package.json';
import { version as eslintVersion } from 'eslint/package.json';
import type { Config } from 'jest';
import * as semver from 'semver';
const config = {
clearMocks: true,
restoreMocks: true,
resetMocks: true,
coverageThreshold: {
global: {
branches: 100,
functions: 100,
lines: 100,
statements: 100,
},
},
projects: [
{
displayName: 'test',
testPathIgnorePatterns: [
'<rootDir>/lib/.*',
'<rootDir>/src/rules/__tests__/fixtures/*',
'<rootDir>/src/rules/__tests__/test-utils.ts',
],
coveragePathIgnorePatterns: ['/node_modules/'],
},
{
displayName: 'lint',
runner: 'jest-runner-eslint',
testMatch: ['<rootDir>/**/*.{js,ts}'],
testPathIgnorePatterns: ['<rootDir>/lib/.*'],
coveragePathIgnorePatterns: ['/node_modules/'],
},
],
} satisfies Config;
if (semver.major(eslintVersion) !== 8) {
// our eslint config only works for v8
config.projects = config.projects.filter(
({ displayName }) => displayName !== 'lint',
);
}
// jest/unbound-method seems to only be happy with @typescript-eslint v7 right now...
if (semver.major(typescriptESLintPluginVersion) !== 7) {
for (const project of config.projects) {
project.testPathIgnorePatterns.push(
'<rootDir>/src/rules/__tests__/unbound-method.test.ts',
);
project.coveragePathIgnorePatterns.push(
'<rootDir>/src/rules/unbound-method.ts',
);
}
}
export default config;