@modern-js/plugin-testing 2.4.1-beta.0 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +40 -6
- package/dist/{js/node → cjs}/base/config/index.js +7 -23
- package/dist/{js/node → cjs}/base/config/patches/assetsModule.js +4 -0
- package/dist/{js/node → cjs}/base/config/patches/index.js +6 -26
- package/dist/{js/node → cjs}/base/config/patches/transformer.js +4 -0
- package/dist/{js/node → cjs}/base/config/resolver.js +4 -0
- package/dist/{js/node → cjs}/base/config/testConfigOperator.js +1 -15
- package/dist/{js/node → cjs}/base/config/transformer/babelTransformer.js +4 -0
- package/dist/{js/node → cjs}/base/runJest.js +28 -48
- package/dist/{js/node → cjs}/base/utils.js +8 -15
- package/dist/{js/node → cjs}/cli/bff/app.js +6 -26
- package/dist/{js/node → cjs}/cli/bff/index.js +26 -49
- package/dist/{js/node → cjs}/cli/bff/mockAPI.js +9 -16
- package/dist/{js/node → cjs}/cli/bff/setup.js +10 -26
- package/dist/{js/node → cjs}/cli/bff/utils/index.js +5 -15
- package/dist/{js/node → cjs}/cli/index.js +13 -26
- package/dist/{js/node → cjs}/cli/test.js +8 -24
- package/dist/{js/node → cjs}/runtime-testing/app.js +8 -15
- package/dist/{js/node → cjs}/runtime-testing/base.js +4 -0
- package/dist/{js/node → cjs}/runtime-testing/customRender.js +5 -15
- package/dist/{js/node → cjs}/runtime-testing/reduck.js +7 -19
- package/dist/{js/node → cjs}/runtime-testing/request.js +4 -0
- package/dist/{js/node → cjs}/runtime-testing/resolvePlugins.js +3 -15
- package/dist/{js/treeshaking → esm}/cli/index.js +3 -0
- package/dist/esm-node/base/config/index.js +16 -0
- package/dist/esm-node/base/config/patches/index.js +14 -0
- package/dist/{js/modern → esm-node}/base/config/testConfigOperator.js +1 -17
- package/dist/esm-node/base/runJest.js +78 -0
- package/dist/{js/modern → esm-node}/base/utils.js +4 -17
- package/dist/esm-node/cli/bff/app.js +38 -0
- package/dist/{js/modern → esm-node}/cli/bff/index.js +22 -51
- package/dist/{js/modern → esm-node}/cli/bff/mockAPI.js +5 -18
- package/dist/esm-node/cli/bff/setup.js +46 -0
- package/dist/esm-node/cli/bff/utils/index.js +21 -0
- package/dist/{js/modern → esm-node}/cli/index.js +9 -26
- package/dist/{js/modern → esm-node}/cli/test.js +4 -24
- package/dist/esm-node/runtime-testing/app.js +35 -0
- package/dist/esm-node/runtime-testing/customRender.js +9 -0
- package/dist/{js/modern → esm-node}/runtime-testing/reduck.js +3 -21
- package/dist/esm-node/runtime-testing/resolvePlugins.js +19 -0
- package/package.json +25 -26
- package/dist/js/modern/base/config/index.js +0 -36
- package/dist/js/modern/base/config/patches/index.js +0 -34
- package/dist/js/modern/base/runJest.js +0 -102
- package/dist/js/modern/cli/bff/app.js +0 -58
- package/dist/js/modern/cli/bff/setup.js +0 -75
- package/dist/js/modern/cli/bff/utils/index.js +0 -37
- package/dist/js/modern/runtime-testing/app.js +0 -48
- package/dist/js/modern/runtime-testing/customRender.js +0 -25
- package/dist/js/modern/runtime-testing/resolvePlugins.js +0 -33
- /package/dist/{js/node → cjs}/base/config/patches/filemock.js +0 -0
- /package/dist/{js/node → cjs}/base/hook.js +0 -0
- /package/dist/{js/node → cjs}/base/index.js +0 -0
- /package/dist/{js/node → cjs}/base/types/index.js +0 -0
- /package/dist/{js/node → cjs}/cli/bff/constant.js +0 -0
- /package/dist/{js/node → cjs}/constant.js +0 -0
- /package/dist/{js/node → cjs}/index.js +0 -0
- /package/dist/{js/node → cjs}/runtime-testing/index.js +0 -0
- /package/dist/{js/treeshaking → esm}/base/config/index.js +0 -0
- /package/dist/{js/treeshaking → esm}/base/config/patches/assetsModule.js +0 -0
- /package/dist/{js/treeshaking → esm}/base/config/patches/filemock.js +0 -0
- /package/dist/{js/treeshaking → esm}/base/config/patches/index.js +0 -0
- /package/dist/{js/treeshaking → esm}/base/config/patches/transformer.js +0 -0
- /package/dist/{js/treeshaking → esm}/base/config/resolver.js +0 -0
- /package/dist/{js/treeshaking → esm}/base/config/testConfigOperator.js +0 -0
- /package/dist/{js/treeshaking → esm}/base/config/transformer/babelTransformer.js +0 -0
- /package/dist/{js/treeshaking → esm}/base/hook.js +0 -0
- /package/dist/{js/treeshaking → esm}/base/index.js +0 -0
- /package/dist/{js/treeshaking → esm}/base/runJest.js +0 -0
- /package/dist/{js/treeshaking → esm}/base/types/index.js +0 -0
- /package/dist/{js/treeshaking → esm}/base/utils.js +0 -0
- /package/dist/{js/treeshaking → esm}/cli/bff/app.js +0 -0
- /package/dist/{js/treeshaking → esm}/cli/bff/constant.js +0 -0
- /package/dist/{js/treeshaking → esm}/cli/bff/index.js +0 -0
- /package/dist/{js/treeshaking → esm}/cli/bff/mockAPI.js +0 -0
- /package/dist/{js/treeshaking → esm}/cli/bff/setup.js +0 -0
- /package/dist/{js/treeshaking → esm}/cli/bff/utils/index.js +0 -0
- /package/dist/{js/treeshaking → esm}/cli/test.js +0 -0
- /package/dist/{js/treeshaking → esm}/constant.js +0 -0
- /package/dist/{js/treeshaking → esm}/index.js +0 -0
- /package/dist/{js/treeshaking → esm}/runtime-testing/app.js +0 -0
- /package/dist/{js/treeshaking → esm}/runtime-testing/base.js +0 -0
- /package/dist/{js/treeshaking → esm}/runtime-testing/customRender.js +0 -0
- /package/dist/{js/treeshaking → esm}/runtime-testing/index.js +0 -0
- /package/dist/{js/treeshaking → esm}/runtime-testing/reduck.js +0 -0
- /package/dist/{js/treeshaking → esm}/runtime-testing/request.js +0 -0
- /package/dist/{js/treeshaking → esm}/runtime-testing/resolvePlugins.js +0 -0
- /package/dist/{js/modern → esm-node}/base/config/patches/assetsModule.js +0 -0
- /package/dist/{js/modern → esm-node}/base/config/patches/filemock.js +0 -0
- /package/dist/{js/modern → esm-node}/base/config/patches/transformer.js +0 -0
- /package/dist/{js/modern → esm-node}/base/config/resolver.js +0 -0
- /package/dist/{js/modern → esm-node}/base/config/transformer/babelTransformer.js +0 -0
- /package/dist/{js/modern → esm-node}/base/hook.js +0 -0
- /package/dist/{js/modern → esm-node}/base/index.js +0 -0
- /package/dist/{js/modern → esm-node}/base/types/index.js +0 -0
- /package/dist/{js/modern → esm-node}/cli/bff/constant.js +0 -0
- /package/dist/{js/modern → esm-node}/constant.js +0 -0
- /package/dist/{js/modern → esm-node}/index.js +0 -0
- /package/dist/{js/modern → esm-node}/runtime-testing/base.js +0 -0
- /package/dist/{js/modern → esm-node}/runtime-testing/index.js +0 -0
- /package/dist/{js/modern → esm-node}/runtime-testing/request.js +0 -0
|
@@ -13,29 +13,13 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
13
13
|
return to;
|
|
14
14
|
};
|
|
15
15
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
18
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
16
20
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
17
21
|
mod
|
|
18
22
|
));
|
|
19
|
-
var __async = (__this, __arguments, generator) => {
|
|
20
|
-
return new Promise((resolve, reject) => {
|
|
21
|
-
var fulfilled = (value) => {
|
|
22
|
-
try {
|
|
23
|
-
step(generator.next(value));
|
|
24
|
-
} catch (e) {
|
|
25
|
-
reject(e);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
var rejected = (value) => {
|
|
29
|
-
try {
|
|
30
|
-
step(generator.throw(value));
|
|
31
|
-
} catch (e) {
|
|
32
|
-
reject(e);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
36
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
37
|
-
});
|
|
38
|
-
};
|
|
39
23
|
var import_path = __toESM(require("path"));
|
|
40
24
|
var import_bff_core = require("@modern-js/bff-core");
|
|
41
25
|
var import_constant = require("./constant");
|
|
@@ -66,19 +50,19 @@ const setup = () => {
|
|
|
66
50
|
{}
|
|
67
51
|
);
|
|
68
52
|
let app = null;
|
|
69
|
-
beforeAll(() =>
|
|
53
|
+
beforeAll(async () => {
|
|
70
54
|
if (!app) {
|
|
71
|
-
app =
|
|
55
|
+
app = await (0, import_app.createApp)(
|
|
72
56
|
bff_info.appDir,
|
|
73
57
|
bff_info.modernUserConfig,
|
|
74
58
|
bff_info.plugins,
|
|
75
59
|
bff_info.routes
|
|
76
60
|
);
|
|
77
61
|
}
|
|
78
|
-
})
|
|
79
|
-
afterAll(() =>
|
|
80
|
-
|
|
81
|
-
})
|
|
62
|
+
});
|
|
63
|
+
afterAll(async () => {
|
|
64
|
+
await (0, import_app.closeServer)();
|
|
65
|
+
});
|
|
82
66
|
(0, import_mockAPI.default)(apiInfosByFile);
|
|
83
67
|
};
|
|
84
68
|
setup();
|
|
@@ -2,22 +2,8 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
-
var __spreadValues = (a, b) => {
|
|
11
|
-
for (var prop in b || (b = {}))
|
|
12
|
-
if (__hasOwnProp.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
if (__getOwnPropSymbols)
|
|
15
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
-
if (__propIsEnum.call(b, prop))
|
|
17
|
-
__defNormalProp(a, prop, b[prop]);
|
|
18
|
-
}
|
|
19
|
-
return a;
|
|
20
|
-
};
|
|
21
7
|
var __export = (target, all) => {
|
|
22
8
|
for (var name in all)
|
|
23
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -31,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
31
17
|
return to;
|
|
32
18
|
};
|
|
33
19
|
var __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.
|
|
34
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
35
25
|
mod
|
|
36
26
|
));
|
|
@@ -46,7 +36,7 @@ const isBFFProject = (pwd) => {
|
|
|
46
36
|
try {
|
|
47
37
|
const packageJson = require(import_path.default.join(pwd, "./package.json"));
|
|
48
38
|
const { dependencies, devDependencies } = packageJson;
|
|
49
|
-
const isBFF = Object.keys(
|
|
39
|
+
const isBFF = Object.keys({ ...dependencies, ...devDependencies }).some(
|
|
50
40
|
(dependency) => dependency.includes("plugin-bff")
|
|
51
41
|
);
|
|
52
42
|
const isMWA = Object.keys(devDependencies).some(
|
|
@@ -17,30 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __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.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
23
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
-
var __async = (__this, __arguments, generator) => {
|
|
25
|
-
return new Promise((resolve, reject) => {
|
|
26
|
-
var fulfilled = (value) => {
|
|
27
|
-
try {
|
|
28
|
-
step(generator.next(value));
|
|
29
|
-
} catch (e) {
|
|
30
|
-
reject(e);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
var rejected = (value) => {
|
|
34
|
-
try {
|
|
35
|
-
step(generator.throw(value));
|
|
36
|
-
} catch (e) {
|
|
37
|
-
reject(e);
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
41
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
28
|
var cli_exports = {};
|
|
45
29
|
__export(cli_exports, {
|
|
46
30
|
default: () => cli_default,
|
|
@@ -70,9 +54,9 @@ var cli_default = () => {
|
|
|
70
54
|
let testingExportsUtils;
|
|
71
55
|
return {
|
|
72
56
|
commands: ({ program }) => {
|
|
73
|
-
program.command("test").allowUnknownOption().usage("<regexForTestFiles> --[options]").action(() =>
|
|
74
|
-
|
|
75
|
-
})
|
|
57
|
+
program.command("test").allowUnknownOption().usage("<regexForTestFiles> --[options]").action(async () => {
|
|
58
|
+
await (0, import_test.default)(api);
|
|
59
|
+
});
|
|
76
60
|
},
|
|
77
61
|
validateSchema() {
|
|
78
62
|
return import_utils.PLUGIN_SCHEMAS["@modern-js/plugin-testing"];
|
|
@@ -86,6 +70,8 @@ var cli_default = () => {
|
|
|
86
70
|
return {
|
|
87
71
|
source: {
|
|
88
72
|
alias: {
|
|
73
|
+
// The module-tools alias configuration is different and more specific than app-tools.
|
|
74
|
+
// So for the time being, the @ alias is configured here.
|
|
89
75
|
"@": import_path.default.join(appContext.appDirectory, "src"),
|
|
90
76
|
"@modern-js/runtime/testing": testingExportsUtils.getPath()
|
|
91
77
|
}
|
|
@@ -96,10 +82,10 @@ var cli_default = () => {
|
|
|
96
82
|
const testingPath = import_path.default.resolve(__dirname, "../");
|
|
97
83
|
testingExportsUtils.addExport(`export * from '${testingPath}'`);
|
|
98
84
|
},
|
|
99
|
-
jestConfig: (utils, next) =>
|
|
85
|
+
jestConfig: async (utils, next) => {
|
|
100
86
|
const appContext = api.useAppContext();
|
|
101
87
|
const userConfig = api.useResolvedConfigContext();
|
|
102
|
-
const apiOnly =
|
|
88
|
+
const apiOnly = await (0, import_utils.isApiOnly)(appContext.appDirectory);
|
|
103
89
|
if (apiOnly) {
|
|
104
90
|
return next(utils);
|
|
105
91
|
}
|
|
@@ -117,6 +103,7 @@ var cli_default = () => {
|
|
|
117
103
|
testEnvironment: "jsdom",
|
|
118
104
|
resolver: import_base.DEFAULT_RESOLVER_PATH,
|
|
119
105
|
rootDir: appContext.appDirectory || process.cwd(),
|
|
106
|
+
// testMatch bug on windows, issue: https://github.com/facebook/jest/issues/7914
|
|
120
107
|
testMatch: [
|
|
121
108
|
`<rootDir>/src/**/*.test.[jt]s?(x)`,
|
|
122
109
|
`<rootDir>/tests/**/*.test.[jt]s?(x)`
|
|
@@ -124,7 +111,7 @@ var cli_default = () => {
|
|
|
124
111
|
});
|
|
125
112
|
mergeUserJestConfig(utils);
|
|
126
113
|
return next(utils);
|
|
127
|
-
}
|
|
114
|
+
}
|
|
128
115
|
};
|
|
129
116
|
}
|
|
130
117
|
};
|
|
@@ -17,30 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __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.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
23
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
-
var __async = (__this, __arguments, generator) => {
|
|
25
|
-
return new Promise((resolve, reject) => {
|
|
26
|
-
var fulfilled = (value) => {
|
|
27
|
-
try {
|
|
28
|
-
step(generator.next(value));
|
|
29
|
-
} catch (e) {
|
|
30
|
-
reject(e);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
var rejected = (value) => {
|
|
34
|
-
try {
|
|
35
|
-
step(generator.throw(value));
|
|
36
|
-
} catch (e) {
|
|
37
|
-
reject(e);
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
41
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
28
|
var test_exports = {};
|
|
45
29
|
__export(test_exports, {
|
|
46
30
|
default: () => test_default
|
|
@@ -49,7 +33,7 @@ module.exports = __toCommonJS(test_exports);
|
|
|
49
33
|
var import_path = __toESM(require("path"));
|
|
50
34
|
var import_babel_compiler = require("@modern-js/babel-compiler");
|
|
51
35
|
var import_base = require("../base");
|
|
52
|
-
const test = (api) =>
|
|
36
|
+
const test = async (api) => {
|
|
53
37
|
var _a, _b;
|
|
54
38
|
const userConfig = api.useResolvedConfigContext();
|
|
55
39
|
const appContext = api.useAppContext();
|
|
@@ -63,7 +47,7 @@ const test = (api) => __async(void 0, null, function* () {
|
|
|
63
47
|
appContext.internalDirectory,
|
|
64
48
|
".runtime-exports"
|
|
65
49
|
);
|
|
66
|
-
|
|
50
|
+
await (0, import_babel_compiler.compiler)(
|
|
67
51
|
{
|
|
68
52
|
sourceDir: runtimeExportsPath,
|
|
69
53
|
rootDir: runtimeExportsPath,
|
|
@@ -81,8 +65,8 @@ const test = (api) => __async(void 0, null, function* () {
|
|
|
81
65
|
]
|
|
82
66
|
}
|
|
83
67
|
);
|
|
84
|
-
|
|
85
|
-
}
|
|
68
|
+
await (0, import_base.runTest)(api, userConfig.testing);
|
|
69
|
+
};
|
|
86
70
|
var test_default = test;
|
|
87
71
|
// Annotate the CommonJS export names for ESM import in node:
|
|
88
72
|
0 && (module.exports = {});
|
|
@@ -2,22 +2,8 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
-
var __spreadValues = (a, b) => {
|
|
11
|
-
for (var prop in b || (b = {}))
|
|
12
|
-
if (__hasOwnProp.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
if (__getOwnPropSymbols)
|
|
15
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
-
if (__propIsEnum.call(b, prop))
|
|
17
|
-
__defNormalProp(a, prop, b[prop]);
|
|
18
|
-
}
|
|
19
|
-
return a;
|
|
20
|
-
};
|
|
21
7
|
var __export = (target, all) => {
|
|
22
8
|
for (var name in all)
|
|
23
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -31,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
31
17
|
return to;
|
|
32
18
|
};
|
|
33
19
|
var __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.
|
|
34
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
35
25
|
mod
|
|
36
26
|
));
|
|
@@ -55,7 +45,10 @@ class ModernRuntime {
|
|
|
55
45
|
const { entry, children } = props || {};
|
|
56
46
|
let runtimeFeatures = (_a = this.options) == null ? void 0 : _a.runtime;
|
|
57
47
|
if (entry) {
|
|
58
|
-
runtimeFeatures =
|
|
48
|
+
runtimeFeatures = {
|
|
49
|
+
...runtimeFeatures || {},
|
|
50
|
+
...(_b = this.options.runtimeByEntries) == null ? void 0 : _b[entry]
|
|
51
|
+
};
|
|
59
52
|
}
|
|
60
53
|
const Component = () => {
|
|
61
54
|
if (!children) {
|
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
};
|
|
19
19
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
|
@@ -2,22 +2,8 @@ var __create = Object.create;
|
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
-
var __spreadValues = (a, b) => {
|
|
11
|
-
for (var prop in b || (b = {}))
|
|
12
|
-
if (__hasOwnProp.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
if (__getOwnPropSymbols)
|
|
15
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
-
if (__propIsEnum.call(b, prop))
|
|
17
|
-
__defNormalProp(a, prop, b[prop]);
|
|
18
|
-
}
|
|
19
|
-
return a;
|
|
20
|
-
};
|
|
21
7
|
var __export = (target, all) => {
|
|
22
8
|
for (var name in all)
|
|
23
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -31,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
31
17
|
return to;
|
|
32
18
|
};
|
|
33
19
|
var __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.
|
|
34
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
35
25
|
mod
|
|
36
26
|
));
|
|
@@ -44,7 +34,7 @@ var import_react = __toESM(require("react"));
|
|
|
44
34
|
var import_react2 = require("@testing-library/react");
|
|
45
35
|
var import_app = __toESM(require("./app"));
|
|
46
36
|
const WrapModernProviders = (props) => import_react.default.createElement(import_app.default.createApp(props));
|
|
47
|
-
const customRender = (ui, options) => (0, import_react2.render)(ui,
|
|
37
|
+
const customRender = (ui, options) => (0, import_react2.render)(ui, { wrapper: WrapModernProviders, ...options });
|
|
48
38
|
var customRender_default = customRender;
|
|
49
39
|
// Annotate the CommonJS export names for ESM import in node:
|
|
50
40
|
0 && (module.exports = {});
|
|
@@ -1,26 +1,9 @@
|
|
|
1
1
|
var __create = Object.create;
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __defProps = Object.defineProperties;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
5
|
var __getProtoOf = Object.getPrototypeOf;
|
|
9
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
-
var __spreadValues = (a, b) => {
|
|
13
|
-
for (var prop in b || (b = {}))
|
|
14
|
-
if (__hasOwnProp.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
if (__getOwnPropSymbols)
|
|
17
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
-
if (__propIsEnum.call(b, prop))
|
|
19
|
-
__defNormalProp(a, prop, b[prop]);
|
|
20
|
-
}
|
|
21
|
-
return a;
|
|
22
|
-
};
|
|
23
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
7
|
var __export = (target, all) => {
|
|
25
8
|
for (var name in all)
|
|
26
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -34,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
34
17
|
return to;
|
|
35
18
|
};
|
|
36
19
|
var __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.
|
|
37
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
38
25
|
mod
|
|
39
26
|
));
|
|
@@ -71,9 +58,10 @@ const createStore = (props) => {
|
|
|
71
58
|
}
|
|
72
59
|
return ((props == null ? void 0 : props.plugins) || []).concat(plugins);
|
|
73
60
|
};
|
|
74
|
-
const config =
|
|
61
|
+
const config = {
|
|
62
|
+
...props || {},
|
|
75
63
|
plugins: createStatePlugins()
|
|
76
|
-
}
|
|
64
|
+
};
|
|
77
65
|
return (0, import_store.createStore)(config);
|
|
78
66
|
};
|
|
79
67
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -17,6 +17,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
return to;
|
|
18
18
|
};
|
|
19
19
|
var __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.
|
|
20
24
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
25
|
mod
|
|
22
26
|
));
|
|
@@ -1,21 +1,7 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
2
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
-
var __spreadValues = (a, b) => {
|
|
9
|
-
for (var prop in b || (b = {}))
|
|
10
|
-
if (__hasOwnProp.call(b, prop))
|
|
11
|
-
__defNormalProp(a, prop, b[prop]);
|
|
12
|
-
if (__getOwnPropSymbols)
|
|
13
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
-
if (__propIsEnum.call(b, prop))
|
|
15
|
-
__defNormalProp(a, prop, b[prop]);
|
|
16
|
-
}
|
|
17
|
-
return a;
|
|
18
|
-
};
|
|
19
5
|
var __export = (target, all) => {
|
|
20
6
|
for (var name in all)
|
|
21
7
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -42,7 +28,9 @@ function resolvePlugins(features) {
|
|
|
42
28
|
}
|
|
43
29
|
Object.keys(features).forEach((feature) => {
|
|
44
30
|
if (allowedFeatures.includes(feature)) {
|
|
45
|
-
const curPluginRes = require(
|
|
31
|
+
const curPluginRes = require("@modern-js/runtime/plugins")[feature]({
|
|
32
|
+
...features[feature]
|
|
33
|
+
});
|
|
46
34
|
plugins.push(curPluginRes);
|
|
47
35
|
}
|
|
48
36
|
});
|
|
@@ -189,6 +189,8 @@ var cli_default = function() {
|
|
|
189
189
|
return {
|
|
190
190
|
source: {
|
|
191
191
|
alias: {
|
|
192
|
+
// The module-tools alias configuration is different and more specific than app-tools.
|
|
193
|
+
// So for the time being, the @ alias is configured here.
|
|
192
194
|
"@": path.join(appContext.appDirectory, "src"),
|
|
193
195
|
"@modern-js/runtime/testing": testingExportsUtils.getPath()
|
|
194
196
|
}
|
|
@@ -231,6 +233,7 @@ var cli_default = function() {
|
|
|
231
233
|
testEnvironment: "jsdom",
|
|
232
234
|
resolver: DEFAULT_RESOLVER_PATH,
|
|
233
235
|
rootDir: appContext.appDirectory || process.cwd(),
|
|
236
|
+
// testMatch bug on windows, issue: https://github.com/facebook/jest/issues/7914
|
|
234
237
|
testMatch: [
|
|
235
238
|
"<rootDir>/src/**/*.test.[jt]s?(x)",
|
|
236
239
|
"<rootDir>/tests/**/*.test.[jt]s?(x)"
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { applyPatches } from "./patches";
|
|
2
|
+
import { TestConfigOperator } from "./testConfigOperator";
|
|
3
|
+
const getJestUtils = (testConfig) => {
|
|
4
|
+
const testOperator = new TestConfigOperator(testConfig);
|
|
5
|
+
return testOperator;
|
|
6
|
+
};
|
|
7
|
+
const patchConfig = async (testOperator) => {
|
|
8
|
+
await applyPatches(testOperator);
|
|
9
|
+
return testOperator.jestConfig;
|
|
10
|
+
};
|
|
11
|
+
const DEFAULT_RESOLVER_PATH = require.resolve("./resolver");
|
|
12
|
+
export {
|
|
13
|
+
DEFAULT_RESOLVER_PATH,
|
|
14
|
+
getJestUtils,
|
|
15
|
+
patchConfig
|
|
16
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { patchTransformer } from "./transformer";
|
|
2
|
+
import { patchAssetsModule } from "./assetsModule";
|
|
3
|
+
const _applyPatches = async (patches2, testOperator) => {
|
|
4
|
+
for (const patch of patches2) {
|
|
5
|
+
await patch(testOperator);
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
const patches = [patchTransformer, patchAssetsModule];
|
|
9
|
+
const applyPatches = async (testConfig) => {
|
|
10
|
+
await _applyPatches(patches, testConfig);
|
|
11
|
+
};
|
|
12
|
+
export {
|
|
13
|
+
applyPatches
|
|
14
|
+
};
|
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
-
var __spreadValues = (a, b) => {
|
|
7
|
-
for (var prop in b || (b = {}))
|
|
8
|
-
if (__hasOwnProp.call(b, prop))
|
|
9
|
-
__defNormalProp(a, prop, b[prop]);
|
|
10
|
-
if (__getOwnPropSymbols)
|
|
11
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
-
if (__propIsEnum.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
}
|
|
15
|
-
return a;
|
|
16
|
-
};
|
|
17
1
|
import { merge } from "@modern-js/utils/lodash";
|
|
18
2
|
class TestConfigOperator {
|
|
19
3
|
constructor(testConfig) {
|
|
@@ -51,7 +35,7 @@ class TestConfigOperator {
|
|
|
51
35
|
return;
|
|
52
36
|
}
|
|
53
37
|
}
|
|
54
|
-
this._jestConfig =
|
|
38
|
+
this._jestConfig = { ...this._jestConfig, ...sourceConfig };
|
|
55
39
|
}
|
|
56
40
|
getFinalConfig() {
|
|
57
41
|
const { userJestConfig } = this;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import yargs from "yargs/yargs";
|
|
2
|
+
import { runCLI } from "jest";
|
|
3
|
+
import { chalk } from "@modern-js/utils";
|
|
4
|
+
import { getJestUtils, patchConfig } from "./config";
|
|
5
|
+
import { debug } from "./utils";
|
|
6
|
+
const buildArgv = async (rawArgv, config) => {
|
|
7
|
+
const argv = await yargs(rawArgv).argv;
|
|
8
|
+
const result = {
|
|
9
|
+
$0: argv.$0,
|
|
10
|
+
_: argv._.slice(1)
|
|
11
|
+
};
|
|
12
|
+
Object.keys(argv).forEach((key) => {
|
|
13
|
+
if (key.includes("-") || key === "_") {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
result[key] = argv[key];
|
|
17
|
+
});
|
|
18
|
+
if (config) {
|
|
19
|
+
result.config = JSON.stringify(config);
|
|
20
|
+
}
|
|
21
|
+
return result;
|
|
22
|
+
};
|
|
23
|
+
const readResultsAndExit = (result, globalConfig) => {
|
|
24
|
+
const code = !result || result.success ? 0 : globalConfig.testFailureExitCode;
|
|
25
|
+
process.on("exit", () => {
|
|
26
|
+
if (typeof code === "number" && code !== 0) {
|
|
27
|
+
process.exitCode = code;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
if (globalConfig.forceExit) {
|
|
31
|
+
if (!globalConfig.detectOpenHandles) {
|
|
32
|
+
console.warn(
|
|
33
|
+
`${chalk.bold(
|
|
34
|
+
"Force exiting Jest: "
|
|
35
|
+
)}Have you considered using \`--detectOpenHandles\` to detect async operations that kept running after all tests finished?`
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
process.exit(code);
|
|
39
|
+
} else if (!globalConfig.detectOpenHandles) {
|
|
40
|
+
setTimeout(() => {
|
|
41
|
+
console.warn(
|
|
42
|
+
chalk.yellow.bold(
|
|
43
|
+
"Jest did not exit one second after the test run has completed.\n\n"
|
|
44
|
+
) + chalk.yellow(
|
|
45
|
+
"This usually means that there are asynchronous operations that weren't stopped in your tests. Consider running Jest with `--detectOpenHandles` to troubleshoot this issue."
|
|
46
|
+
)
|
|
47
|
+
);
|
|
48
|
+
}, 1e3).unref();
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
async function runJest(config, pwd = process.cwd()) {
|
|
52
|
+
try {
|
|
53
|
+
const argvConfig = await buildArgv(process.argv.slice(2), config);
|
|
54
|
+
const { results, globalConfig } = await runCLI(argvConfig, [pwd]);
|
|
55
|
+
readResultsAndExit(results, globalConfig);
|
|
56
|
+
} catch (e) {
|
|
57
|
+
console.error(chalk.red((e == null ? void 0 : e.stack) || e));
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
async function runTest(api, config, pwd = process.cwd()) {
|
|
62
|
+
process.env.NODE_ENV = "test";
|
|
63
|
+
const jestUtils = getJestUtils(config);
|
|
64
|
+
await patchConfig(jestUtils);
|
|
65
|
+
jestUtils.setJestUserConfig();
|
|
66
|
+
const hookRunners = api.useHookRunners();
|
|
67
|
+
const testConfigOperator = await hookRunners.jestConfig(jestUtils, {
|
|
68
|
+
onLast: (input) => input
|
|
69
|
+
});
|
|
70
|
+
const finalConfig = testConfigOperator.getFinalConfig();
|
|
71
|
+
debug("Jest config:", finalConfig);
|
|
72
|
+
await runJest(finalConfig, pwd);
|
|
73
|
+
await hookRunners.afterTest();
|
|
74
|
+
}
|
|
75
|
+
export {
|
|
76
|
+
runJest,
|
|
77
|
+
runTest
|
|
78
|
+
};
|
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
-
var __spreadValues = (a, b) => {
|
|
7
|
-
for (var prop in b || (b = {}))
|
|
8
|
-
if (__hasOwnProp.call(b, prop))
|
|
9
|
-
__defNormalProp(a, prop, b[prop]);
|
|
10
|
-
if (__getOwnPropSymbols)
|
|
11
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
-
if (__propIsEnum.call(b, prop))
|
|
13
|
-
__defNormalProp(a, prop, b[prop]);
|
|
14
|
-
}
|
|
15
|
-
return a;
|
|
16
|
-
};
|
|
17
1
|
import fs from "fs";
|
|
18
2
|
import path from "path";
|
|
19
3
|
import { createDebugger } from "@modern-js/utils";
|
|
@@ -42,7 +26,10 @@ const readCompilerOptions = (pwd = process.cwd(), filename = "tsconfig.json") =>
|
|
|
42
26
|
tsConfig.extends
|
|
43
27
|
);
|
|
44
28
|
}
|
|
45
|
-
return
|
|
29
|
+
return {
|
|
30
|
+
...extendedCompilerOptions,
|
|
31
|
+
...tsConfig.compilerOptions
|
|
32
|
+
};
|
|
46
33
|
};
|
|
47
34
|
const getModuleNameMapper = (alias) => Object.keys(alias).reduce((memo, cur) => {
|
|
48
35
|
const aliasValue = Array.isArray(alias[cur]) ? alias[cur] : [alias[cur]];
|