-
-
Notifications
You must be signed in to change notification settings - Fork 241
/
jest.config.mjs
120 lines (115 loc) · 3.45 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
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*eslint-env node*/
import { ConfigSet, pathsToModuleNameMapper } from 'ts-jest';
import * as path from 'path';
import * as fs from 'fs';
import { fileURLToPath } from 'url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const { compilerOptions } = JSON.parse(fs.readFileSync('./tsconfig.json', 'utf8'));
const projectDefault = {
moduleNameMapper: {
...Object.fromEntries(
Object.entries(pathsToModuleNameMapper(compilerOptions.paths)).map(([k, v]) => [k, path.join(__dirname, v)]),
),
'^@stoplight/spectral\\-test\\-utils$': '<rootDir>/test-utils/node/index.ts',
},
testEnvironment: 'node',
transform: {
'^.+\\.ts$': ['@swc/jest'],
},
};
const config = {
workerIdleMemoryLimit: '1024MB',
};
export default {
projects: [
{
...projectDefault,
displayName: {
name: '@stoplight/spectral-cli',
color: 'greenBright',
},
testMatch: ['<rootDir>/packages/cli/src/**/__tests__/**/*.{test,spec}.ts'],
},
{
...projectDefault,
displayName: {
name: '@stoplight/spectral-core',
color: 'magenta',
},
testMatch: ['<rootDir>/packages/core/src/**/__tests__/**/*.{test,spec}.ts'],
},
{
...projectDefault,
displayName: {
name: '@stoplight/spectral-formats',
color: 'redBright',
},
testMatch: ['<rootDir>/packages/formats/src/**/__tests__/**/*.{test,spec}.ts'],
},
{
...projectDefault,
displayName: {
name: '@stoplight/spectral-functions',
color: 'blueBright',
},
testMatch: ['<rootDir>/packages/functions/src/**/__tests__/**/*.{test,spec}.ts'],
},
{
...projectDefault,
displayName: {
name: '@stoplight/spectral-ruleset-bundler',
color: 'blueBright',
},
setupFilesAfterEnv: ['<rootDir>/packages/ruleset-bundler/jest.setup.mjs'],
testMatch: ['<rootDir>/packages/ruleset-bundler/src/**/__tests__/**/*.{test,spec}.ts'],
},
{
...projectDefault,
displayName: {
name: '@stoplight/spectral-ruleset-migrator',
color: 'blueBright',
},
testMatch: ['<rootDir>/packages/ruleset-migrator/src/**/__tests__/**/*.{test,spec}.ts'],
},
{
...projectDefault,
displayName: '@stoplight/spectral-parsers',
testMatch: ['<rootDir>/packages/parsers/src/**/__tests__/**/*.{test,spec}.ts'],
},
{
...projectDefault,
displayName: {
name: '@stoplight/spectral-ref-resolver',
color: 'yellow',
},
testMatch: ['<rootDir>/packages/ref-resolver/src/**/__tests__/**/*.{test,spec}.ts'],
},
{
...projectDefault,
displayName: {
name: '@stoplight/spectral-rulesets',
color: 'cyanBright',
},
setupFilesAfterEnv: ['<rootDir>/packages/rulesets/jest.setup.mjs'],
testMatch: ['<rootDir>/packages/rulesets/src/**/__tests__/**/*.{test,spec}.ts'],
},
{
...projectDefault,
displayName: {
name: '@stoplight/spectral-runtime',
color: 'blue',
},
testMatch: ['<rootDir>/packages/runtime/src/**/__tests__/*.{test,spec}.ts'],
},
{
...projectDefault,
displayName: {
name: '@stoplight/spectral-formatters',
color: 'magenta',
},
testMatch: ['<rootDir>/packages/formatters/src/**/__tests__/*.{test,spec}.ts'],
},
],
collectCoverageFrom: ['<rootDir>/packages/*/src/**/*.ts', '!<rootDir>/packages/*/src/**/__*__/**/*.ts'],
...config,
};