-
Notifications
You must be signed in to change notification settings - Fork 241
/
Copy pathjest.config.js
45 lines (42 loc) · 1.61 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
import path, { dirname } from "node:path";
import { fileURLToPath } from "node:url";
import { buildVars } from "../../scripts/buildVars.js";
export function currentDirName(importMetaUrl) {
return dirname(fileURLToPath(importMetaUrl));
}
const globals = {};
buildVars.forEach(({ name, defaultValue }) => {
globals[name] = process.env[name] || defaultValue;
});
const currentDir = currentDirName(import.meta.url);
export default {
testEnvironment: "jsdom",
moduleNameMapper: {
"react-markdown": path.resolve(currentDir, "./mocks/react-markdown.js"),
"\\.md\\?url$": path.resolve(currentDir, "./mocks/markdown-url-module.js"),
"^@lowcoder-ee(.*)$": path.resolve(
currentDir, "../../packages/lowcoder/src/$1"
),
"lowcoder-sdk": path.resolve(currentDir, "../../packages/lowcoder/src/index.sdk"),
},
globals,
// roots: ["<rootDir>/src"],
modulePaths: [
"<rootDir>/src",
path.resolve(currentDir, "../../packages/lowcoder/src"),
path.resolve(currentDir, "../../packages/lowcoder-comps/src"),
path.resolve(currentDir, "../../packages/lowcoder-design/src"),
],
setupFiles: [path.resolve(currentDir, "./jest.setup.js")],
setupFilesAfterEnv: [path.resolve(currentDir, "./jest.setup-after-env.js"), 'jest-canvas-mock'],
transform: {
"^.+\\.(js|jsx|mjs|cjs|ts|tsx)$": path.resolve(currentDir, "./transform/babelTransform.js"),
"^.+\\.css$": path.resolve(currentDir, "./transform/cssTransform.js"),
"^(?!.*\\.(js|jsx|mjs|cjs|ts|tsx|css|json)$)": path.resolve(
currentDir,
"./transform/fileTransform.js"
),
},
transformIgnorePatterns: [],
resetMocks: true,
};