@modern-js/plugin-testing 2.4.0 → 2.5.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.
Files changed (101) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/{js/node → cjs}/base/config/index.js +3 -23
  3. package/dist/{js/node → cjs}/base/config/patches/assetsModule.js +0 -0
  4. package/dist/{js/node → cjs}/base/config/patches/filemock.js +0 -0
  5. package/dist/{js/node → cjs}/base/config/patches/index.js +6 -26
  6. package/dist/{js/node → cjs}/base/config/patches/transformer.js +0 -0
  7. package/dist/{js/node → cjs}/base/config/resolver.js +0 -0
  8. package/dist/{js/node → cjs}/base/config/testConfigOperator.js +1 -15
  9. package/dist/{js/node → cjs}/base/config/transformer/babelTransformer.js +0 -0
  10. package/dist/{js/node → cjs}/base/hook.js +0 -0
  11. package/dist/{js/node → cjs}/base/index.js +0 -0
  12. package/dist/{js/node → cjs}/base/runJest.js +24 -48
  13. package/dist/{js/node → cjs}/base/types/index.js +0 -0
  14. package/dist/{js/node → cjs}/base/utils.js +4 -15
  15. package/dist/{js/node → cjs}/cli/bff/app.js +6 -26
  16. package/dist/{js/node → cjs}/cli/bff/constant.js +0 -0
  17. package/dist/{js/node → cjs}/cli/bff/index.js +22 -49
  18. package/dist/{js/node → cjs}/cli/bff/mockAPI.js +5 -16
  19. package/dist/{js/node → cjs}/cli/bff/setup.js +6 -26
  20. package/dist/{js/node → cjs}/cli/bff/utils/index.js +1 -15
  21. package/dist/{js/node → cjs}/cli/index.js +6 -26
  22. package/dist/{js/node → cjs}/cli/test.js +4 -24
  23. package/dist/{js/node → cjs}/constant.js +0 -0
  24. package/dist/{js/node → cjs}/index.js +0 -0
  25. package/dist/{js/node → cjs}/runtime-testing/app.js +4 -15
  26. package/dist/{js/node → cjs}/runtime-testing/base.js +0 -0
  27. package/dist/{js/node → cjs}/runtime-testing/customRender.js +1 -15
  28. package/dist/{js/node → cjs}/runtime-testing/index.js +0 -0
  29. package/dist/{js/node → cjs}/runtime-testing/reduck.js +3 -19
  30. package/dist/{js/node → cjs}/runtime-testing/request.js +0 -0
  31. package/dist/{js/node → cjs}/runtime-testing/resolvePlugins.js +3 -15
  32. package/dist/{js/treeshaking → esm}/base/config/index.js +0 -0
  33. package/dist/{js/treeshaking → esm}/base/config/patches/assetsModule.js +0 -0
  34. package/dist/{js/treeshaking → esm}/base/config/patches/filemock.js +0 -0
  35. package/dist/{js/treeshaking → esm}/base/config/patches/index.js +0 -0
  36. package/dist/{js/treeshaking → esm}/base/config/patches/transformer.js +0 -0
  37. package/dist/{js/treeshaking → esm}/base/config/resolver.js +0 -0
  38. package/dist/{js/treeshaking → esm}/base/config/testConfigOperator.js +0 -0
  39. package/dist/{js/treeshaking → esm}/base/config/transformer/babelTransformer.js +2 -2
  40. package/dist/{js/treeshaking → esm}/base/hook.js +0 -0
  41. package/dist/{js/treeshaking → esm}/base/index.js +0 -0
  42. package/dist/{js/treeshaking → esm}/base/runJest.js +2 -2
  43. package/dist/{js/treeshaking → esm}/base/types/index.js +0 -0
  44. package/dist/{js/treeshaking → esm}/base/utils.js +0 -0
  45. package/dist/{js/treeshaking → esm}/cli/bff/app.js +0 -0
  46. package/dist/{js/treeshaking → esm}/cli/bff/constant.js +0 -0
  47. package/dist/{js/treeshaking → esm}/cli/bff/index.js +2 -2
  48. package/dist/{js/treeshaking → esm}/cli/bff/mockAPI.js +1 -1
  49. package/dist/{js/treeshaking → esm}/cli/bff/setup.js +2 -2
  50. package/dist/{js/treeshaking → esm}/cli/bff/utils/index.js +0 -0
  51. package/dist/{js/treeshaking → esm}/cli/index.js +0 -0
  52. package/dist/{js/treeshaking → esm}/cli/test.js +3 -3
  53. package/dist/{js/treeshaking → esm}/constant.js +0 -0
  54. package/dist/{js/treeshaking → esm}/index.js +0 -0
  55. package/dist/{js/treeshaking → esm}/runtime-testing/app.js +5 -5
  56. package/dist/{js/treeshaking → esm}/runtime-testing/base.js +0 -0
  57. package/dist/{js/treeshaking → esm}/runtime-testing/customRender.js +0 -0
  58. package/dist/{js/treeshaking → esm}/runtime-testing/index.js +0 -0
  59. package/dist/{js/treeshaking → esm}/runtime-testing/reduck.js +2 -2
  60. package/dist/{js/treeshaking → esm}/runtime-testing/request.js +0 -0
  61. package/dist/{js/treeshaking → esm}/runtime-testing/resolvePlugins.js +0 -0
  62. package/dist/esm-node/base/config/index.js +16 -0
  63. package/dist/{js/modern → esm-node}/base/config/patches/assetsModule.js +0 -0
  64. package/dist/{js/modern → esm-node}/base/config/patches/filemock.js +0 -0
  65. package/dist/esm-node/base/config/patches/index.js +14 -0
  66. package/dist/{js/modern → esm-node}/base/config/patches/transformer.js +0 -0
  67. package/dist/{js/modern → esm-node}/base/config/resolver.js +0 -0
  68. package/dist/{js/modern → esm-node}/base/config/testConfigOperator.js +1 -17
  69. package/dist/{js/modern → esm-node}/base/config/transformer/babelTransformer.js +0 -0
  70. package/dist/{js/modern → esm-node}/base/hook.js +0 -0
  71. package/dist/{js/modern → esm-node}/base/index.js +0 -0
  72. package/dist/esm-node/base/runJest.js +78 -0
  73. package/dist/{js/modern → esm-node}/base/types/index.js +0 -0
  74. package/dist/{js/modern → esm-node}/base/utils.js +4 -17
  75. package/dist/esm-node/cli/bff/app.js +38 -0
  76. package/dist/{js/modern → esm-node}/cli/bff/constant.js +0 -0
  77. package/dist/{js/modern → esm-node}/cli/bff/index.js +22 -51
  78. package/dist/{js/modern → esm-node}/cli/bff/mockAPI.js +5 -18
  79. package/dist/esm-node/cli/bff/setup.js +46 -0
  80. package/dist/esm-node/cli/bff/utils/index.js +21 -0
  81. package/dist/{js/modern → esm-node}/cli/index.js +6 -26
  82. package/dist/{js/modern → esm-node}/cli/test.js +4 -24
  83. package/dist/{js/modern → esm-node}/constant.js +0 -0
  84. package/dist/{js/modern → esm-node}/index.js +0 -0
  85. package/dist/esm-node/runtime-testing/app.js +35 -0
  86. package/dist/{js/modern → esm-node}/runtime-testing/base.js +0 -0
  87. package/dist/esm-node/runtime-testing/customRender.js +9 -0
  88. package/dist/{js/modern → esm-node}/runtime-testing/index.js +0 -0
  89. package/dist/{js/modern → esm-node}/runtime-testing/reduck.js +3 -21
  90. package/dist/{js/modern → esm-node}/runtime-testing/request.js +0 -0
  91. package/dist/esm-node/runtime-testing/resolvePlugins.js +19 -0
  92. package/package.json +25 -26
  93. package/dist/js/modern/base/config/index.js +0 -36
  94. package/dist/js/modern/base/config/patches/index.js +0 -34
  95. package/dist/js/modern/base/runJest.js +0 -102
  96. package/dist/js/modern/cli/bff/app.js +0 -58
  97. package/dist/js/modern/cli/bff/setup.js +0 -75
  98. package/dist/js/modern/cli/bff/utils/index.js +0 -37
  99. package/dist/js/modern/runtime-testing/app.js +0 -48
  100. package/dist/js/modern/runtime-testing/customRender.js +0 -25
  101. package/dist/js/modern/runtime-testing/resolvePlugins.js +0 -33
@@ -21,26 +21,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
21
21
  mod
22
22
  ));
23
23
  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
24
  var cli_exports = {};
45
25
  __export(cli_exports, {
46
26
  default: () => cli_default,
@@ -70,9 +50,9 @@ var cli_default = () => {
70
50
  let testingExportsUtils;
71
51
  return {
72
52
  commands: ({ program }) => {
73
- program.command("test").allowUnknownOption().usage("<regexForTestFiles> --[options]").action(() => __async(void 0, null, function* () {
74
- yield (0, import_test.default)(api);
75
- }));
53
+ program.command("test").allowUnknownOption().usage("<regexForTestFiles> --[options]").action(async () => {
54
+ await (0, import_test.default)(api);
55
+ });
76
56
  },
77
57
  validateSchema() {
78
58
  return import_utils.PLUGIN_SCHEMAS["@modern-js/plugin-testing"];
@@ -96,10 +76,10 @@ var cli_default = () => {
96
76
  const testingPath = import_path.default.resolve(__dirname, "../");
97
77
  testingExportsUtils.addExport(`export * from '${testingPath}'`);
98
78
  },
99
- jestConfig: (utils, next) => __async(void 0, null, function* () {
79
+ jestConfig: async (utils, next) => {
100
80
  const appContext = api.useAppContext();
101
81
  const userConfig = api.useResolvedConfigContext();
102
- const apiOnly = yield (0, import_utils.isApiOnly)(appContext.appDirectory);
82
+ const apiOnly = await (0, import_utils.isApiOnly)(appContext.appDirectory);
103
83
  if (apiOnly) {
104
84
  return next(utils);
105
85
  }
@@ -124,7 +104,7 @@ var cli_default = () => {
124
104
  });
125
105
  mergeUserJestConfig(utils);
126
106
  return next(utils);
127
- })
107
+ }
128
108
  };
129
109
  }
130
110
  };
@@ -21,26 +21,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
21
21
  mod
22
22
  ));
23
23
  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
24
  var test_exports = {};
45
25
  __export(test_exports, {
46
26
  default: () => test_default
@@ -49,7 +29,7 @@ module.exports = __toCommonJS(test_exports);
49
29
  var import_path = __toESM(require("path"));
50
30
  var import_babel_compiler = require("@modern-js/babel-compiler");
51
31
  var import_base = require("../base");
52
- const test = (api) => __async(void 0, null, function* () {
32
+ const test = async (api) => {
53
33
  var _a, _b;
54
34
  const userConfig = api.useResolvedConfigContext();
55
35
  const appContext = api.useAppContext();
@@ -63,7 +43,7 @@ const test = (api) => __async(void 0, null, function* () {
63
43
  appContext.internalDirectory,
64
44
  ".runtime-exports"
65
45
  );
66
- yield (0, import_babel_compiler.compiler)(
46
+ await (0, import_babel_compiler.compiler)(
67
47
  {
68
48
  sourceDir: runtimeExportsPath,
69
49
  rootDir: runtimeExportsPath,
@@ -81,8 +61,8 @@ const test = (api) => __async(void 0, null, function* () {
81
61
  ]
82
62
  }
83
63
  );
84
- yield (0, import_base.runTest)(api, userConfig.testing);
85
- });
64
+ await (0, import_base.runTest)(api, userConfig.testing);
65
+ };
86
66
  var test_default = test;
87
67
  // Annotate the CommonJS export names for ESM import in node:
88
68
  0 && (module.exports = {});
File without changes
File without changes
@@ -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 });
@@ -55,7 +41,10 @@ class ModernRuntime {
55
41
  const { entry, children } = props || {};
56
42
  let runtimeFeatures = (_a = this.options) == null ? void 0 : _a.runtime;
57
43
  if (entry) {
58
- runtimeFeatures = __spreadValues(__spreadValues({}, runtimeFeatures || {}), (_b = this.options.runtimeByEntries) == null ? void 0 : _b[entry]);
44
+ runtimeFeatures = {
45
+ ...runtimeFeatures || {},
46
+ ...(_b = this.options.runtimeByEntries) == null ? void 0 : _b[entry]
47
+ };
59
48
  }
60
49
  const Component = () => {
61
50
  if (!children) {
File without changes
@@ -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 });
@@ -44,7 +30,7 @@ var import_react = __toESM(require("react"));
44
30
  var import_react2 = require("@testing-library/react");
45
31
  var import_app = __toESM(require("./app"));
46
32
  const WrapModernProviders = (props) => import_react.default.createElement(import_app.default.createApp(props));
47
- const customRender = (ui, options) => (0, import_react2.render)(ui, __spreadValues({ wrapper: WrapModernProviders }, options));
33
+ const customRender = (ui, options) => (0, import_react2.render)(ui, { wrapper: WrapModernProviders, ...options });
48
34
  var customRender_default = customRender;
49
35
  // Annotate the CommonJS export names for ESM import in node:
50
36
  0 && (module.exports = {});
File without changes
@@ -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 });
@@ -71,9 +54,10 @@ const createStore = (props) => {
71
54
  }
72
55
  return ((props == null ? void 0 : props.plugins) || []).concat(plugins);
73
56
  };
74
- const config = __spreadProps(__spreadValues({}, props || {}), {
57
+ const config = {
58
+ ...props || {},
75
59
  plugins: createStatePlugins()
76
- });
60
+ };
77
61
  return (0, import_store.createStore)(config);
78
62
  };
79
63
  // Annotate the CommonJS export names for ESM import in node:
File without changes
@@ -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(`@modern-js/runtime/plugins`)[feature](__spreadValues({}, features[feature]));
31
+ const curPluginRes = require(`@modern-js/runtime/plugins`)[feature]({
32
+ ...features[feature]
33
+ });
46
34
  plugins.push(curPluginRes);
47
35
  }
48
36
  });
@@ -1,6 +1,6 @@
1
- var ref;
1
+ var _babelJest_createTransformer;
2
2
  import babelJest from "babel-jest";
3
- var babelTransformer = (ref = babelJest.createTransformer) === null || ref === void 0 ? void 0 : ref.call(babelJest, {
3
+ var babelTransformer = (_babelJest_createTransformer = babelJest.createTransformer) === null || _babelJest_createTransformer === void 0 ? void 0 : _babelJest_createTransformer.call(babelJest, {
4
4
  presets: [
5
5
  [
6
6
  require.resolve("@modern-js/babel-preset-app"),
File without changes
File without changes
@@ -186,7 +186,7 @@ function runJest(config) {
186
186
  }
187
187
  function _runJest() {
188
188
  _runJest = _asyncToGenerator(function(config) {
189
- var pwd, argvConfig, ref, results, globalConfig, e;
189
+ var pwd, argvConfig, _ref, results, globalConfig, e;
190
190
  var _arguments = arguments;
191
191
  return __generator(this, function(_state) {
192
192
  switch(_state.label){
@@ -213,7 +213,7 @@ function _runJest() {
213
213
  ])
214
214
  ];
215
215
  case 3:
216
- ref = _state.sent(), results = ref.results, globalConfig = ref.globalConfig;
216
+ _ref = _state.sent(), results = _ref.results, globalConfig = _ref.globalConfig;
217
217
  readResultsAndExit(results, globalConfig);
218
218
  return [
219
219
  3,
File without changes
File without changes
File without changes
File without changes
@@ -157,7 +157,7 @@ import { bff_info_key } from "./constant";
157
157
  import { isBFFProject } from "./utils";
158
158
  var setJestConfigForBFF = function() {
159
159
  var _ref = _asyncToGenerator(function(param) {
160
- var pwd, userConfig, plugins, routes, utils, ref, bffConfig, jestConfig, alias, aliasMapper, moduleNameMapper, transform, apiOnly, mergedModuleNameMapper, resolver, configFields, commonConfig;
160
+ var pwd, userConfig, plugins, routes, utils, _userConfig_source, bffConfig, jestConfig, alias, aliasMapper, moduleNameMapper, transform, apiOnly, mergedModuleNameMapper, resolver, configFields, commonConfig;
161
161
  return __generator(this, function(_state) {
162
162
  switch(_state.label){
163
163
  case 0:
@@ -185,7 +185,7 @@ var setJestConfigForBFF = function() {
185
185
  })
186
186
  };
187
187
  jestConfig = utils.jestConfig;
188
- alias = (userConfig === null || userConfig === void 0 ? void 0 : (ref = userConfig.source) === null || ref === void 0 ? void 0 : ref.alias) || {};
188
+ alias = (userConfig === null || userConfig === void 0 ? void 0 : (_userConfig_source = userConfig.source) === null || _userConfig_source === void 0 ? void 0 : _userConfig_source.alias) || {};
189
189
  aliasMapper = getModuleNameMapper(alias);
190
190
  moduleNameMapper = jestConfig.moduleNameMapper;
191
191
  transform = {
@@ -142,7 +142,7 @@ var mockAPI_default = function(mockApiInfosByFile) {
142
142
  var _info;
143
143
  return (_info = info).handler.apply(_info, _toConsumableArray(args));
144
144
  }
145
- var ref = _slicedToArray(mock_getParamsAndPayload(args), 2), params = ref[0], payload = ref[1];
145
+ var _mock_getParamsAndPayload = _slicedToArray(mock_getParamsAndPayload(args), 2), params = _mock_getParamsAndPayload[0], payload = _mock_getParamsAndPayload[1];
146
146
  var returnHttp = module[info.name].returnHttp;
147
147
  var url = mock_replaceUrlWithParams(info.routePath, params, payload.params);
148
148
  var app = mockAppModule.getApp();
@@ -129,13 +129,13 @@ import mockAPI from "./mockAPI";
129
129
  import { createApp, closeServer } from "./app";
130
130
  var uped = false;
131
131
  var setup = function() {
132
- var ref, ref1;
132
+ var _bff_info_modernUserConfig, _bff_info_modernUserConfig_bff;
133
133
  if (uped) {
134
134
  return;
135
135
  }
136
136
  uped = true;
137
137
  var bff_info = global[bff_info_key];
138
- var prefix = bff_info === null || bff_info === void 0 ? void 0 : (ref = bff_info.modernUserConfig) === null || ref === void 0 ? void 0 : (ref1 = ref.bff) === null || ref1 === void 0 ? void 0 : ref1.prefix;
138
+ var prefix = bff_info === null || bff_info === void 0 ? void 0 : (_bff_info_modernUserConfig = bff_info.modernUserConfig) === null || _bff_info_modernUserConfig === void 0 ? void 0 : (_bff_info_modernUserConfig_bff = _bff_info_modernUserConfig.bff) === null || _bff_info_modernUserConfig_bff === void 0 ? void 0 : _bff_info_modernUserConfig_bff.prefix;
139
139
  var apiRouter = new ApiRouter({
140
140
  apiDir: path.join(bff_info.appDir, "./api"),
141
141
  prefix: prefix
File without changes
@@ -127,18 +127,18 @@ import { compiler } from "@modern-js/babel-compiler";
127
127
  import { runTest } from "../base";
128
128
  var test = function() {
129
129
  var _ref = _asyncToGenerator(function(api) {
130
- var ref, ref1, userConfig, appContext, jest, runtimeExportsPath;
130
+ var _userConfig_tools, _userConfig_tools1, userConfig, appContext, jest, runtimeExportsPath;
131
131
  return __generator(this, function(_state) {
132
132
  switch(_state.label){
133
133
  case 0:
134
134
  userConfig = api.useResolvedConfigContext();
135
135
  appContext = api.useAppContext();
136
136
  userConfig.testing = userConfig.testing || {};
137
- jest = userConfig.testing.jest || (userConfig === null || userConfig === void 0 ? void 0 : (ref = userConfig.tools) === null || ref === void 0 ? void 0 : ref.jest);
137
+ jest = userConfig.testing.jest || (userConfig === null || userConfig === void 0 ? void 0 : (_userConfig_tools = userConfig.tools) === null || _userConfig_tools === void 0 ? void 0 : _userConfig_tools.jest);
138
138
  if (Array.isArray(jest)) {
139
139
  userConfig.testing.jest = jest[0];
140
140
  }
141
- userConfig.testing.jest = userConfig.testing.jest || (userConfig === null || userConfig === void 0 ? void 0 : (ref1 = userConfig.tools) === null || ref1 === void 0 ? void 0 : ref1.jest);
141
+ userConfig.testing.jest = userConfig.testing.jest || (userConfig === null || userConfig === void 0 ? void 0 : (_userConfig_tools1 = userConfig.tools) === null || _userConfig_tools1 === void 0 ? void 0 : _userConfig_tools1.jest);
142
142
  runtimeExportsPath = path.join(appContext.internalDirectory, ".runtime-exports");
143
143
  return [
144
144
  4,
File without changes
File without changes
@@ -65,12 +65,12 @@ var ModernRuntime = /*#__PURE__*/ function() {
65
65
  {
66
66
  key: "createApp",
67
67
  value: function createApp1(props) {
68
- var ref;
69
- var ref1 = props || {}, entry = ref1.entry, children = ref1.children;
70
- var runtimeFeatures = (ref = this.options) === null || ref === void 0 ? void 0 : ref.runtime;
68
+ var _this_options;
69
+ var _ref = props || {}, entry = _ref.entry, children = _ref.children;
70
+ var runtimeFeatures = (_this_options = this.options) === null || _this_options === void 0 ? void 0 : _this_options.runtime;
71
71
  if (entry) {
72
- var ref2;
73
- runtimeFeatures = _objectSpread({}, runtimeFeatures || {}, (ref2 = this.options.runtimeByEntries) === null || ref2 === void 0 ? void 0 : ref2[entry]);
72
+ var _this_options_runtimeByEntries;
73
+ runtimeFeatures = _objectSpread({}, runtimeFeatures || {}, (_this_options_runtimeByEntries = this.options.runtimeByEntries) === null || _this_options_runtimeByEntries === void 0 ? void 0 : _this_options_runtimeByEntries[entry]);
74
74
  }
75
75
  var Component = function() {
76
76
  if (!children) {
@@ -66,9 +66,9 @@ var autoActions = function() {
66
66
  };
67
67
  var createStore = function(props) {
68
68
  var createStatePlugins = function() {
69
- var ref;
69
+ var _modernConfig_runtime;
70
70
  var modernConfig = global[MODERNJS_CONFIG_KEY];
71
- var stateConfig = modernConfig === null || modernConfig === void 0 ? void 0 : (ref = modernConfig.runtime) === null || ref === void 0 ? void 0 : ref.state;
71
+ var stateConfig = modernConfig === null || modernConfig === void 0 ? void 0 : (_modernConfig_runtime = modernConfig.runtime) === null || _modernConfig_runtime === void 0 ? void 0 : _modernConfig_runtime.state;
72
72
  var plugins = [];
73
73
  if ((stateConfig === null || stateConfig === void 0 ? void 0 : stateConfig.effects) !== false) {
74
74
  plugins.push(effects());
@@ -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 = __spreadValues(__spreadValues({}, this._jestConfig), sourceConfig);
38
+ this._jestConfig = { ...this._jestConfig, ...sourceConfig };
55
39
  }
56
40
  getFinalConfig() {
57
41
  const { userJestConfig } = this;
File without changes
File without changes
@@ -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
+ };
File without changes