-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathjest.config.js
49 lines (45 loc) · 1.06 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
/* eslint-disable @typescript-eslint/no-var-requires */
const { pipe, D, A } = require("@mobily/ts-belt");
const { pathsToModuleNameMapper } = require("ts-jest");
const { compilerOptions } = require("./tsconfig");
// The order that the "paths" keys need to be in
// order for jest to be able to resolve the imports
const requiredPathsKeyOrder = ["$root/*", "$tests/*", "$*"];
const orderedKeys = pipe(
compilerOptions.paths,
D.toPairs,
A.sortBy(([key]) => requiredPathsKeyOrder.indexOf(key)),
D.fromPairs
);
const config = {
preset: "ts-jest",
moduleNameMapper: pathsToModuleNameMapper(orderedKeys, {
prefix: "<rootDir>/../../",
}),
setupFilesAfterEnv: ["<rootDir>/../setup/jest.setup.ts"],
};
module.exports = {
testTimeout: 10000,
reporters: [
[
"jest-compact-reporter",
{
showPassingTests: true,
},
],
],
projects: [
{
displayName: "frontend",
rootDir: "./tests/frontend",
testEnvironment: "jsdom",
...config,
},
{
displayName: "backend",
rootDir: "./tests/backend",
testEnvironment: "node",
...config,
},
],
};