-
Notifications
You must be signed in to change notification settings - Fork 157
/
jest.config.js
80 lines (76 loc) · 2.45 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
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
const { pathsToModuleNameMapper } = require('ts-jest');
// const { defaults: tsjPreset } = require('ts-jest/presets');
// const { jsWithTs: tsjPreset } = require('ts-jest/presets');
// const { jsWithBabel: tsjPreset } = require('ts-jest/presets');
// console.log(tsjPreset.transform);
const { compilerOptions } = require("./tsconfig");
// const fs = require("fs");
// const compilerOptions = JSON.parse(fs.readFileSync("./tsconfig.json", { encoding: "utf8" })).compilerOptions;
const pathMaps = pathsToModuleNameMapper(compilerOptions.paths, { prefix: "<rootDir>/" } );
// console.log(pathMaps);
const moduleNameMapper = {
"readium-desktop/main/di": "<rootDir>/test/main/di.ts", // se src/common/utils.ts convertMultiLangStringToString()
...pathMaps,
// ...{
// "^@r2\\-streamer\\-js/(.*)$": "<rootDir>/scripts/jest_void.ts",
// "^@r2\\-navigator\\-js/(.*)$": "<rootDir>/scripts/jest_void.ts",
// },
};
// console.log(moduleNameMapper);
module.exports = {
verbose: true,
testEnvironment: "node",
preset: "ts-jest",
// globals: {
// },
transform: {
"\\.ts$": "<rootDir>/scripts/jest_preprocessor.js",
// ...tsjPreset.transform,
"\\.tsx?$": ["ts-jest", {
babelConfig: false,
tsconfig: "<rootDir>/tsconfig.json",
}],
},
moduleNameMapper,
moduleFileExtensions: [
"ts",
"tsx",
"js",
"jsx",
"json",
],
transformIgnorePatterns: [
"<rootDir>/node_modules/",
"<rootDir>/dist/",
"<rootDir>/resources/",
"<rootDir>/changelogs/",
"<rootDir>/docs/",
"<rootDir>/img/",
"<rootDir>/release/",
"<rootDir>/scripts/",
],
modulePathIgnorePatterns: [
"<rootDir>/node_modules/",
"<rootDir>/dist/",
"<rootDir>/resources/",
"<rootDir>/changelogs/",
"<rootDir>/docs/",
"<rootDir>/img/",
"<rootDir>/release/",
"<rootDir>/scripts/",
"<rootDir>/src/",
],
testPathIgnorePatterns: [
"<rootDir>/node_modules/",
"<rootDir>/dist/",
"<rootDir>/resources/",
"<rootDir>/changelogs/",
"<rootDir>/docs/",
"<rootDir>/img/",
"<rootDir>/release/",
"<rootDir>/scripts/",
"<rootDir>/src/",
],
setupFilesAfterEnv: ['<rootDir>/scripts/jest_setup.js'],
// runner: '@jest-runner/electron/main', // package.json dev dep: @jest-runner/electron
};