-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfig.ts
61 lines (52 loc) · 1.7 KB
/
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
60
61
import path from "path";
import { ENV_MODULE_DIR, ENV_JEST_VSC_RUN } from "../const";
import { getJestConfig } from "../config";
import { getModuleDirs } from "../utils";
import type { Config } from "jest";
export const getConfig = (moduleDir: string): Config => {
const jestConfig = getJestConfig();
const rootDir = path.resolve(moduleDir, "..", "..");
const roots = [moduleDir];
// put module dir as env var
process.env[ENV_MODULE_DIR] = moduleDir;
const isVscRun = process.env[ENV_JEST_VSC_RUN] !== undefined;
const config: Config = {
// cache: true,
rootDir,
roots,
verbose: isVscRun,
maxConcurrency: jestConfig.maxConcurrency,
testEnvironment: "<rootDir>/lib/core/src/jest/environment",
moduleNameMapper: {
"^@lib/(.*)$": "<rootDir>/lib/$1",
"^@test/(.*)$": "<rootDir>/test/$1",
typescript: require.resolve("typescript"),
"ts-node": require.resolve("ts-node"),
"ts-jest": require.resolve("ts-jest"),
"selenium-webdriver": require.resolve("selenium-webdriver"),
},
runner: "<rootDir>/lib/core/src/jest/runner",
testRunner: require.resolve("jest-circus/runner"),
setupFilesAfterEnv: [
"<rootDir>/lib/core/src/jest/setExpect.ts",
"<rootDir>/lib/core/src/jest/setTimeout.ts",
],
globalSetup: "<rootDir>/lib/core/src/jest/globalSetup.ts",
reporters: ["default"],
transform: {
"\\.ts": [
require.resolve("ts-jest"),
{
tsconfig: path.resolve(moduleDir, "tsconfig.json"),
},
],
},
};
if (!isVscRun) {
config.reporters?.push([
"<rootDir>/lib/core/src/jest/reporter",
{ outputDir: getModuleDirs().outputDir },
]);
}
return config;
};