-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathjest.config.js
54 lines (44 loc) · 1.54 KB
/
jest.config.js
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
const path = require('node:path');
const puppeteerPreset = require('jest-puppeteer/jest-preset');
const tsPreset = require('ts-jest/presets/js-with-ts/jest-preset');
const isUnittest = process.env.TYPE === 'unittest';
const isE2E = process.env.TYPE === 'e2e';
const presetObj = isUnittest ? tsPreset : isE2E ? { ...tsPreset, ...puppeteerPreset } : {};
const testPath = isUnittest ? 'src' : isE2E ? 'e2e' : undefined;
const testRegex = [
'__test__/.*\\.([cm]?js|jsx|ts|tsx)$',
'(.*\\.)?(test|spec)\\.([cm]?js|jsx|ts|tsx)$',
].map((s) => {
if (testPath) {
s = `${testPath}/(.*/)*${s}`;
}
return s;
});
const maxWorkers = isUnittest ? '75%' : isE2E ? 1 : undefined;
const testTimeout = isE2E ? 30000 : undefined;
const setupFilesAfterEnv = isUnittest
? ['jest-extended/all', '<rootDir>/additional-configs/jestSetupAfterEnvUnit.ts']
: isE2E
? ['jest-extended/all', 'expect-puppeteer']
: [];
const globalSetup = isE2E ? '<rootDir>/additional-configs/jestGlobalSetupE2E.ts' : undefined;
const globalTeardown = isE2E ? '<rootDir>/additional-configs/jestGlobalTeardownE2E.ts' : undefined;
if (isE2E) {
process.env.JEST_PUPPETEER_CONFIG = path.resolve('additional-configs/.jest-puppeteerrc.json');
}
/**
* @type {import("jest").Config}
**/
const jestConf = {
testEnvironment: 'jsdom',
...presetObj,
testRegex,
maxWorkers,
testTimeout,
setupFilesAfterEnv,
globalSetup,
globalTeardown,
transformIgnorePatterns: ['/node_modules/(?!statofu/src/)'],
modulePathIgnorePatterns: ['<rootDir>/verdaccio/storage'],
};
module.exports = jestConf;