UNPKG

3.51 kBJavaScriptView Raw
1var __create = Object.create;
2var __defProp = Object.defineProperty;
3var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4var __getOwnPropNames = Object.getOwnPropertyNames;
5var __getProtoOf = Object.getPrototypeOf;
6var __hasOwnProp = Object.prototype.hasOwnProperty;
7var __export = (target, all) => {
8 for (var name in all)
9 __defProp(target, name, { get: all[name], enumerable: true });
10};
11var __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};
19var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20 // If the importer is in node compatibility mode or this is not an ESM
21 // file that has been converted to a CommonJS file using a Babel-
22 // compatible transform (i.e. "__esModule" has not been set), then set
23 // "default" to the CommonJS "module.exports" for node compatibility.
24 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25 mod
26));
27var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
29// src/index.ts
30var src_exports = {};
31__export(src_exports, {
32 createConfig: () => createConfig
33});
34module.exports = __toCommonJS(src_exports);
35var import_utils = require("@umijs/utils");
36var import_path = require("path");
37function getJSTransformer(jsTransformer, opts) {
38 switch (jsTransformer) {
39 case "esbuild":
40 return [
41 require.resolve((0, import_path.join)(__dirname, "transformers/esbuild")),
42 {
43 // See https://github.com/umijs/umi/issues/10412
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}
57function 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 // in case of config.test.ts
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// Annotate the CommonJS export names for ESM import in node:
960 && (module.exports = {
97 createConfig
98});