1 | var __create = Object.create;
|
2 | var __defProp = Object.defineProperty;
|
3 | var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4 | var __getOwnPropNames = Object.getOwnPropertyNames;
|
5 | var __getProtoOf = Object.getPrototypeOf;
|
6 | var __hasOwnProp = Object.prototype.hasOwnProperty;
|
7 | var __export = (target, all) => {
|
8 | for (var name in all)
|
9 | __defProp(target, name, { get: all[name], enumerable: true });
|
10 | };
|
11 | var __copyProps = (to, from, except, desc) => {
|
12 | if (from && typeof from === "object" || typeof from === "function") {
|
13 | for (let key of __getOwnPropNames(from))
|
14 | if (!__hasOwnProp.call(to, key) && key !== except)
|
15 | __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
16 | }
|
17 | return to;
|
18 | };
|
19 | var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
25 | mod
|
26 | ));
|
27 | var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
28 |
|
29 |
|
30 | var src_exports = {};
|
31 | __export(src_exports, {
|
32 | createConfig: () => createConfig
|
33 | });
|
34 | module.exports = __toCommonJS(src_exports);
|
35 | var import_utils = require("@umijs/utils");
|
36 | var import_path = require("path");
|
37 | function getJSTransformer(jsTransformer, opts) {
|
38 | switch (jsTransformer) {
|
39 | case "esbuild":
|
40 | return [
|
41 | require.resolve((0, import_path.join)(__dirname, "transformers/esbuild")),
|
42 | {
|
43 |
|
44 | target: "es2020",
|
45 | ...opts,
|
46 | sourcemap: true
|
47 | }
|
48 | ];
|
49 | case "swc":
|
50 | return require.resolve("@swc-node/jest");
|
51 | case "ts-jest":
|
52 | return require.resolve("ts-jest");
|
53 | default:
|
54 | throw new Error(`Unknown jsTransformer: ${jsTransformer}`);
|
55 | }
|
56 | }
|
57 | function createConfig(opts) {
|
58 | (0, import_utils.setNoDeprecation)();
|
59 | const config = {
|
60 | testMatch: ["**/*.test.(t|j)s(x)?"],
|
61 | testPathIgnorePatterns: [
|
62 | "/node_modules/",
|
63 | "<rootDir>/config/",
|
64 |
|
65 | "<rootDir>/mock/",
|
66 | "<rootDir>/.umirc.test.ts"
|
67 | ],
|
68 | transform: {
|
69 | "^.+\\.(t|j)sx?$": getJSTransformer(
|
70 | (opts == null ? void 0 : opts.jsTransformer) || "esbuild",
|
71 | opts == null ? void 0 : opts.jsTransformerOpts
|
72 | ),
|
73 | "^.+\\.mjs$": getJSTransformer(
|
74 | (opts == null ? void 0 : opts.jsTransformer) || "esbuild",
|
75 | opts == null ? void 0 : opts.jsTransformerOpts
|
76 | )
|
77 | },
|
78 | moduleNameMapper: {
|
79 | "^.+\\.(css|less|sass|scss|stylus)$": require.resolve("identity-obj-proxy")
|
80 | },
|
81 | testTimeout: 3e4,
|
82 | transformIgnorePatterns: [`/node_modules/(?!${[].join("|")})`],
|
83 | modulePathIgnorePatterns: [
|
84 | "<rootDir>/packages/.+/compiled",
|
85 | "<rootDir>/packages/.+/fixtures"
|
86 | ],
|
87 | setupFiles: [require.resolve("../setupFiles/shim")],
|
88 | resolver: require.resolve("./resolver.js")
|
89 | };
|
90 | if ((opts == null ? void 0 : opts.target) === "browser") {
|
91 | config.testEnvironment = "jsdom";
|
92 | }
|
93 | return config;
|
94 | }
|
95 |
|
96 | 0 && (module.exports = {
|
97 | createConfig
|
98 | });
|