forked from metabase/metabase
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjest.config.js
More file actions
145 lines (139 loc) · 5.28 KB
/
jest.config.js
File metadata and controls
145 lines (139 loc) · 5.28 KB
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
// @ts-check
/** eslint-disable-next-line import/no-commonjs */
const esmPackages = require("./jest.esm-packages.js");
const baseConfig = {
moduleNameMapper: {
// Force jose to use Node.js runtime instead of browser runtime in jsdom environment.
// The browser runtime expects CryptoKey to be globally available, which jsdom doesn't provide.
"^jose$": "<rootDir>/node_modules/jose/dist/node/cjs/index.js",
"^build-configs/(.*)$": "<rootDir>/frontend/build/$1",
"\\.(css|less)$": "<rootDir>/frontend/test/__mocks__/styleMock.js",
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$":
"<rootDir>/frontend/test/__mocks__/fileMock.js",
"^cljs/(.*)$": "<rootDir>/target/cljs_dev/$1",
"\\.svg\\?(component|source)":
"<rootDir>/frontend/test/__mocks__/svgMock.tsx",
"csv-parse/browser/esm/sync":
"<rootDir>/node_modules/csv-parse/dist/cjs/sync",
"csv-stringify/browser/esm/sync":
"<rootDir>/node_modules/csv-stringify/dist/cjs/sync",
/**
* SDK components import root SDK folder (`embedding-sdk`) that contains the ee plugins.
* This isn't a problem in the core app because we seem to not import to entry file directly
* for any component under tests.
*/
"sdk-ee-plugins": "<rootDir>/frontend/src/metabase/plugins/noop.ts",
/**
* SDK iframe embedding imports the embedding sdk and its components.
* We want to exclude the SDK from the main app's bundle to reduce the bundle size.
*/
"sdk-iframe-embedding-ee-plugins":
"<rootDir>/frontend/src/metabase/lib/noop.ts",
"ee-plugins": "<rootDir>/frontend/src/metabase/lib/noop.ts",
/**
* Imports which are only applicable to the embedding sdk.
* As we use SDK components in new iframe embedding, we need to import them here.
**/
"sdk-specific-imports": "<rootDir>/frontend/src/metabase/lib/noop.ts",
"docs/(.*)$": "<rootDir>/docs/$1",
},
transformIgnorePatterns: [
// Combined pattern for both flat and bun isolated node_modules structures
// - Flat: node_modules/<pkg>/ where <pkg> is NOT in esmPackages
// - Bun: node_modules/.bun/<pkg>@<ver>/ where <pkg> is NOT in esmPackages
`<rootDir>/node_modules/(?:\\.bun/(?!(${esmPackages.join("|")})@)|(?!\\.bun)(?!(${esmPackages.join("|")})/))`,
],
testPathIgnorePatterns: [
"<rootDir>/frontend/.*/.*.tz.unit.spec.{js,jsx,ts,tsx}",
"<rootDir>/release/.*",
],
testMatch: [
"<rootDir>/**/*.unit.spec.js",
"<rootDir>/**/*.unit.spec.{js,jsx,ts,tsx}",
],
modulePaths: [
"<rootDir>/frontend/test",
"<rootDir>/frontend/src",
"<rootDir>/enterprise/frontend/src",
],
modulePathIgnorePatterns: [
"<rootDir>/target/cljs_release/.*",
"<rootDir>/resources/frontend_client",
"<rootDir>/.*/__mocks__",
],
setupFiles: [
"<rootDir>/frontend/test/jest-setup.js",
"<rootDir>/frontend/test/metabase-bootstrap.js",
"<rootDir>/frontend/test/register-visualizations.js",
],
setupFilesAfterEnv: ["<rootDir>/frontend/test/jest-setup-env.js"],
globals: {
ga: {},
},
coverageDirectory: "./coverage",
collectCoverageFrom: [
"frontend/src/**/*.{js,jsx,ts,tsx}",
"enterprise/frontend/src/**/*.{js,jsx,ts,tsx}",
"!<rootDir>/**/*.styled.{js,jsx,ts,tsx}",
"!<rootDir>/**/*.story.{js,jsx,ts,tsx}",
"!<rootDir>/**/*.info.{js,jsx,ts,tsx}",
"!<rootDir>/**/*.unit.spec.{js,jsx,ts,tsx}",
],
coveragePathIgnorePatterns: [
"/node_modules/",
"/frontend/src/metabase/visualizations/lib/errors.js",
"/target/cljs_dev/",
"/target/cljs_release/",
"/frontend/test/",
],
testEnvironment: "jest-environment-jsdom",
};
/** @type {import('jest').Config} */
const config = {
reporters: ["default", "jest-junit"],
coverageReporters: ["html", "lcov"],
watchPlugins: [
"jest-watch-typeahead/filename",
"jest-watch-typeahead/testname",
],
testTimeout: 30000,
projects: [
{
...baseConfig,
displayName: "sdk",
testMatch: [
"<rootDir>/frontend/src/embedding-sdk-{bundle,shared}/**/*.unit.spec.{js,jsx,ts,tsx}",
"<rootDir>/enterprise/frontend/src/embedding-sdk-package/**/*.unit.spec.{js,jsx,ts,tsx}",
"<rootDir>/enterprise/frontend/src/embedding-sdk-ee/**/*.unit.spec.{js,jsx,ts,tsx}",
],
setupFiles: [
...baseConfig.setupFiles,
"<rootDir>/frontend/src/embedding-sdk-shared/jest/setup-env.js",
],
setupFilesAfterEnv: [
...baseConfig.setupFilesAfterEnv,
"<rootDir>/frontend/src/embedding-sdk-shared/jest/setup-after-env.js",
"<rootDir>/frontend/src/embedding-sdk-shared/jest/console-restrictions.js",
],
},
{
...baseConfig,
displayName: "core",
testPathIgnorePatterns: [
...(baseConfig.testPathIgnorePatterns || []),
"<rootDir>/frontend/src/embedding-sdk-bundle",
"<rootDir>/frontend/src/embedding-sdk-shared",
"<rootDir>/enterprise/frontend/src/embedding-sdk-package",
"<rootDir>/enterprise/frontend/src/embedding-sdk-ee",
"<rootDir>/frontend/lint/tests",
],
},
{
displayName: "lint-rules",
testMatch: ["<rootDir>/frontend/lint/tests/**/*.unit.spec.js"],
testEnvironment: "node",
transformIgnorePatterns: baseConfig.transformIgnorePatterns,
},
],
};
module.exports = config;