-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjest.config.ts
66 lines (61 loc) · 1.81 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
import type { Config } from "jest";
const config: Config = {
testEnvironment: "jest-environment-jsdom",
setupFilesAfterEnv: ["<rootDir>/tests/unit/setupTests.tsx"],
testMatch: ["<rootDir>/tests/unit/**/*.spec.ts?(x)"], // directories to find tests
verbose: true,
bail: true, // exit after first test failure
transform: {
"^.+\\.(t|j)sx?$": [
"@swc/jest",
{
jsc: {
transform: {
optimizer: {
globals: {
vars: {
"import.meta.env": "{}",
},
},
},
react: {
runtime: "automatic",
},
},
},
},
],
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$":
"<rootDir>/tests/unit/utils/fileTransformer.js",
"^.+\\.svg": "jest-transformer-svg",
},
moduleNameMapper: {
// order is important
// mocks and stubs
"\\.(css|scss)$": "<rootDir>/tests/unit/mocks/fileMock.js",
// import query parameters
"^@/(.*)\\.css\\?raw$": "<rootDir>/tests/unit/mocks/fileMock.js", // for css imported as string
// import aliases
"@/(.*)$": "<rootDir>/src/$1",
"@tests/(.*)$": "<rootDir>/tests/$1",
},
// coverage
collectCoverageFrom: ["src/**/*.{js,jsx,ts,tsx}"],
coverageReporters: ["html", "lcov"],
coveragePathIgnorePatterns: [
"node_modules",
"src/api/generated/index.tsx",
"\\.(styles|constants)\\.(js|jsx|ts|tsx)$", // ignore .styles.extension and .constants.extension files
],
coverageDirectory: "<rootDir>/tests/unit/coverage",
// TODO: uncomment it when mui is deleted
// coverageThreshold: {
// global: {
// branches: 50,
// functions: 50,
// lines: 50,
// statements: 50,
// },
// },
};
export default config;