-
Notifications
You must be signed in to change notification settings - Fork 72
/
jest.config.ts
82 lines (76 loc) · 2.17 KB
/
jest.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import type { Config } from "jest";
import nextJest from "next/jest";
/*
* Jest config necessary for Next.js
* Next.js tests require jsdom to run
* https://nextjs.org/docs/testing
*/
const jsdomConfig = async (): Promise<any> => {
const createJestConfig = nextJest({
dir: "./packages/cli",
});
const customJestConfig = {
displayName: {
name: "jest.jsdom",
color: "magenta",
},
testEnvironment: "<rootDir>/jsdom.env.ts",
setupFilesAfterEnv: ["<rootDir>/testSetup.ts"],
testMatch: [
"<rootDir>/packages/cli/src/pages/**/__test__/**/*.test.[jt]s?(x)",
"<rootDir>/packages/cli/src/components/**/__test__/**/*.test.[jt]s?(x)",
],
modulePathIgnorePatterns: [
"<rootDir>/packages/.*/__mocks__/index.ts",
"<rootDir>/packages/.*/.mailing/*",
],
};
return createJestConfig(customJestConfig)() as Promise<Config>;
};
/*
* Jest config necessary for everything else
* These can be run with node, which is faster than jsdom
*/
const nodeConfig = (): Config => {
return {
displayName: {
name: "jest.node",
color: "cyan",
},
preset: "ts-jest",
testEnvironment: "node",
setupFilesAfterEnv: ["<rootDir>/testSetup.ts"],
// TODO: keep testTimeout low and use jest.setTimeout for long ones
transform: {
"^.+\\.(ts|tsx)$": "ts-jest",
"^.+\\.(js)$": "babel-jest",
},
testPathIgnorePatterns: [
"e2e",
"<rootDir>/emails/",
"<rootDir>/.mailing/",
"<rootDir>/packages/cli/.mailing/",
"<rootDir>/packages/cli/src/pages",
"<rootDir>/packages/cli/src/components",
],
watchPathIgnorePatterns: [
"<rootDir>/emails/",
"<rootDir>/packages/cli/src/emails/",
"<rootDir>/.mailing/",
"tmp-testMailQueue.json",
],
modulePathIgnorePatterns: [
"<rootDir>/packages/.*/__mocks__/index.ts",
"<rootDir>/packages/.*/.mailing/*",
],
testMatch: ["<rootDir>/packages/**/__test__/**/*.test.[jt]s?(x)"],
};
};
const config = async (): Promise<Config> => {
return {
reporters: ["default", "github-actions"],
testTimeout: 120000,
projects: [nodeConfig(), await jsdomConfig()],
};
};
export default config;