@modern-js/plugin-testing 2.14.0 → 2.16.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 (88) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/cjs/base/config/index.js +15 -39
  3. package/dist/cjs/base/config/patches/assetsModule.js +7 -35
  4. package/dist/cjs/base/config/patches/filemock.js +8 -24
  5. package/dist/cjs/base/config/patches/index.js +13 -28
  6. package/dist/cjs/base/config/patches/transformer.js +13 -38
  7. package/dist/cjs/base/config/resolver.js +23 -26
  8. package/dist/cjs/base/config/testConfigOperator.js +39 -38
  9. package/dist/cjs/base/config/transformer/babelTransformer.js +16 -37
  10. package/dist/cjs/base/hook.js +17 -31
  11. package/dist/cjs/base/index.js +36 -41
  12. package/dist/cjs/base/runJest.js +31 -57
  13. package/dist/cjs/base/types/index.js +4 -15
  14. package/dist/cjs/base/utils.js +30 -53
  15. package/dist/cjs/cli/bff/app.js +17 -32
  16. package/dist/cjs/cli/bff/constant.js +7 -25
  17. package/dist/cjs/cli/bff/index.js +71 -92
  18. package/dist/cjs/cli/bff/mockAPI.js +115 -92
  19. package/dist/cjs/cli/bff/setup.js +30 -51
  20. package/dist/cjs/cli/bff/utils/index.js +21 -45
  21. package/dist/cjs/cli/index.js +43 -59
  22. package/dist/cjs/cli/test.js +35 -62
  23. package/dist/cjs/constant.js +7 -25
  24. package/dist/cjs/index.js +20 -19
  25. package/dist/cjs/runtime-testing/app.js +40 -45
  26. package/dist/cjs/runtime-testing/base.js +34 -40
  27. package/dist/cjs/runtime-testing/customRender.js +21 -39
  28. package/dist/cjs/runtime-testing/index.js +19 -18
  29. package/dist/cjs/runtime-testing/reduck.js +35 -55
  30. package/dist/cjs/runtime-testing/request.js +16 -39
  31. package/dist/cjs/runtime-testing/resolvePlugins.js +12 -25
  32. package/dist/esm/base/config/index.js +146 -139
  33. package/dist/esm/base/config/patches/assetsModule.js +7 -8
  34. package/dist/esm/base/config/patches/filemock.js +1 -2
  35. package/dist/esm/base/config/patches/index.js +214 -207
  36. package/dist/esm/base/config/patches/transformer.js +27 -28
  37. package/dist/esm/base/config/resolver.js +22 -35
  38. package/dist/esm/base/config/testConfigOperator.js +119 -116
  39. package/dist/esm/base/config/transformer/babelTransformer.js +12 -13
  40. package/dist/esm/base/hook.js +5 -6
  41. package/dist/esm/base/index.js +5 -6
  42. package/dist/esm/base/runJest.js +270 -264
  43. package/dist/esm/base/types/index.js +1 -1
  44. package/dist/esm/base/utils.js +66 -67
  45. package/dist/esm/cli/bff/app.js +187 -179
  46. package/dist/esm/cli/bff/constant.js +1 -2
  47. package/dist/esm/cli/bff/index.js +285 -278
  48. package/dist/esm/cli/bff/mockAPI.js +177 -163
  49. package/dist/esm/cli/bff/setup.js +182 -174
  50. package/dist/esm/cli/bff/utils/index.js +40 -41
  51. package/dist/esm/cli/index.js +249 -242
  52. package/dist/esm/cli/test.js +172 -166
  53. package/dist/esm/constant.js +1 -2
  54. package/dist/esm/runtime-testing/app.js +79 -77
  55. package/dist/esm/runtime-testing/base.js +2 -3
  56. package/dist/esm/runtime-testing/customRender.js +30 -31
  57. package/dist/esm/runtime-testing/reduck.js +72 -73
  58. package/dist/esm/runtime-testing/request.js +55 -45
  59. package/dist/esm/runtime-testing/resolvePlugins.js +38 -39
  60. package/dist/esm-node/base/config/index.js +2 -6
  61. package/dist/esm-node/base/config/patches/assetsModule.js +1 -4
  62. package/dist/esm-node/base/config/patches/filemock.js +1 -4
  63. package/dist/esm-node/base/config/patches/index.js +5 -5
  64. package/dist/esm-node/base/config/patches/transformer.js +5 -5
  65. package/dist/esm-node/base/config/resolver.js +20 -19
  66. package/dist/esm-node/base/config/testConfigOperator.js +30 -13
  67. package/dist/esm-node/base/config/transformer/babelTransformer.js +3 -6
  68. package/dist/esm-node/base/hook.js +3 -8
  69. package/dist/esm-node/base/index.js +5 -13
  70. package/dist/esm-node/base/runJest.js +8 -20
  71. package/dist/esm-node/base/types/index.js +1 -0
  72. package/dist/esm-node/base/utils.js +8 -17
  73. package/dist/esm-node/cli/bff/app.js +2 -7
  74. package/dist/esm-node/cli/bff/constant.js +1 -4
  75. package/dist/esm-node/cli/bff/index.js +43 -54
  76. package/dist/esm-node/cli/bff/mockAPI.js +65 -59
  77. package/dist/esm-node/cli/bff/setup.js +11 -19
  78. package/dist/esm-node/cli/bff/utils/index.js +6 -10
  79. package/dist/esm-node/cli/index.js +11 -23
  80. package/dist/esm-node/cli/test.js +19 -28
  81. package/dist/esm-node/constant.js +1 -4
  82. package/dist/esm-node/runtime-testing/app.js +22 -10
  83. package/dist/esm-node/runtime-testing/base.js +2 -6
  84. package/dist/esm-node/runtime-testing/customRender.js +5 -5
  85. package/dist/esm-node/runtime-testing/reduck.js +10 -16
  86. package/dist/esm-node/runtime-testing/request.js +1 -3
  87. package/dist/esm-node/runtime-testing/resolvePlugins.js +6 -6
  88. package/package.json +18 -14
@@ -1,127 +1,130 @@
1
- function _classCallCheck(instance, Constructor) {
2
- if (!(instance instanceof Constructor)) {
3
- throw new TypeError("Cannot call a class as a function");
4
- }
1
+ function _class_call_check(instance, Constructor) {
2
+ if (!(instance instanceof Constructor)) {
3
+ throw new TypeError("Cannot call a class as a function");
4
+ }
5
5
  }
6
6
  function _defineProperties(target, props) {
7
- for(var i = 0; i < props.length; i++){
8
- var descriptor = props[i];
9
- descriptor.enumerable = descriptor.enumerable || false;
10
- descriptor.configurable = true;
11
- if ("value" in descriptor) descriptor.writable = true;
12
- Object.defineProperty(target, descriptor.key, descriptor);
13
- }
7
+ for (var i = 0; i < props.length; i++) {
8
+ var descriptor = props[i];
9
+ descriptor.enumerable = descriptor.enumerable || false;
10
+ descriptor.configurable = true;
11
+ if ("value" in descriptor)
12
+ descriptor.writable = true;
13
+ Object.defineProperty(target, descriptor.key, descriptor);
14
+ }
14
15
  }
15
- function _createClass(Constructor, protoProps, staticProps) {
16
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
17
- if (staticProps) _defineProperties(Constructor, staticProps);
18
- return Constructor;
16
+ function _create_class(Constructor, protoProps, staticProps) {
17
+ if (protoProps)
18
+ _defineProperties(Constructor.prototype, protoProps);
19
+ if (staticProps)
20
+ _defineProperties(Constructor, staticProps);
21
+ return Constructor;
19
22
  }
20
- function _defineProperty(obj, key, value) {
21
- if (key in obj) {
22
- Object.defineProperty(obj, key, {
23
- value: value,
24
- enumerable: true,
25
- configurable: true,
26
- writable: true
27
- });
28
- } else {
29
- obj[key] = value;
30
- }
31
- return obj;
23
+ function _define_property(obj, key, value) {
24
+ if (key in obj) {
25
+ Object.defineProperty(obj, key, {
26
+ value,
27
+ enumerable: true,
28
+ configurable: true,
29
+ writable: true
30
+ });
31
+ } else {
32
+ obj[key] = value;
33
+ }
34
+ return obj;
32
35
  }
33
- function _objectSpread(target) {
34
- for(var i = 1; i < arguments.length; i++){
35
- var source = arguments[i] != null ? arguments[i] : {};
36
- var ownKeys = Object.keys(source);
37
- if (typeof Object.getOwnPropertySymbols === "function") {
38
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
39
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
40
- }));
41
- }
42
- ownKeys.forEach(function(key) {
43
- _defineProperty(target, key, source[key]);
44
- });
36
+ function _object_spread(target) {
37
+ for (var i = 1; i < arguments.length; i++) {
38
+ var source = arguments[i] != null ? arguments[i] : {};
39
+ var ownKeys = Object.keys(source);
40
+ if (typeof Object.getOwnPropertySymbols === "function") {
41
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
42
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
43
+ }));
45
44
  }
46
- return target;
45
+ ownKeys.forEach(function(key) {
46
+ _define_property(target, key, source[key]);
47
+ });
48
+ }
49
+ return target;
47
50
  }
48
51
  import { merge } from "@modern-js/utils/lodash";
49
- var TestConfigOperator = /*#__PURE__*/ function() {
50
- "use strict";
51
- function TestConfigOperator(testConfig) {
52
- _classCallCheck(this, TestConfigOperator);
53
- _defineProperty(this, "_testConfig", void 0);
54
- _defineProperty(this, "_jestConfig", void 0);
55
- _defineProperty(this, "userJestConfig", void 0);
56
- _defineProperty(this, "defaultTestConfig", {
57
- transformer: "babel-jest"
58
- });
59
- this._testConfig = testConfig;
60
- this._jestConfig = {};
61
- this.userJestConfig = testConfig.jest;
62
- this.initial();
63
- }
64
- _createClass(TestConfigOperator, [
65
- {
66
- key: "initial",
67
- value: function initial() {
68
- this._testConfig = merge({}, this.defaultTestConfig, this.testConfig);
69
- }
70
- },
71
- {
72
- key: "jestConfig",
73
- get: function get() {
74
- return this._jestConfig;
75
- }
76
- },
77
- {
78
- key: "testConfig",
79
- get: function get() {
80
- return this._testConfig;
81
- }
82
- },
83
- {
84
- key: "mergeJestConfig",
85
- value: function mergeJestConfig(sourceConfig) {
86
- this._jestConfig = merge({}, this._jestConfig, sourceConfig);
87
- }
88
- },
89
- {
90
- key: "setJestUserConfig",
91
- value: function setJestUserConfig() {
92
- var userJestConfig = this.userJestConfig;
93
- if (typeof userJestConfig === "object") {
94
- this.setJestConfig(userJestConfig);
95
- }
96
- }
97
- },
98
- {
99
- key: "setJestConfig",
100
- value: function setJestConfig(sourceConfig, options) {
101
- if (options) {
102
- var force = options.force;
103
- if (force) {
104
- this._jestConfig = sourceConfig;
105
- return;
106
- }
107
- }
108
- this._jestConfig = _objectSpread({}, this._jestConfig, sourceConfig);
109
- }
110
- },
111
- {
112
- key: "getFinalConfig",
113
- value: function getFinalConfig() {
114
- var userJestConfig = this.userJestConfig;
115
- if (!userJestConfig) {
116
- return this._jestConfig;
117
- }
118
- if (typeof userJestConfig === "function") {
119
- return userJestConfig(this._jestConfig);
120
- }
121
- return this.jestConfig;
122
- }
52
+ var TestConfigOperator = /* @__PURE__ */ function() {
53
+ "use strict";
54
+ function TestConfigOperator2(testConfig) {
55
+ _class_call_check(this, TestConfigOperator2);
56
+ _define_property(this, "_testConfig", void 0);
57
+ _define_property(this, "_jestConfig", void 0);
58
+ _define_property(this, "userJestConfig", void 0);
59
+ _define_property(this, "defaultTestConfig", {
60
+ transformer: "babel-jest"
61
+ });
62
+ this._testConfig = testConfig;
63
+ this._jestConfig = {};
64
+ this.userJestConfig = testConfig.jest;
65
+ this.initial();
66
+ }
67
+ _create_class(TestConfigOperator2, [
68
+ {
69
+ key: "initial",
70
+ value: function initial() {
71
+ this._testConfig = merge({}, this.defaultTestConfig, this.testConfig);
72
+ }
73
+ },
74
+ {
75
+ key: "jestConfig",
76
+ get: function get() {
77
+ return this._jestConfig;
78
+ }
79
+ },
80
+ {
81
+ key: "testConfig",
82
+ get: function get() {
83
+ return this._testConfig;
84
+ }
85
+ },
86
+ {
87
+ key: "mergeJestConfig",
88
+ value: function mergeJestConfig(sourceConfig) {
89
+ this._jestConfig = merge({}, this._jestConfig, sourceConfig);
90
+ }
91
+ },
92
+ {
93
+ key: "setJestUserConfig",
94
+ value: function setJestUserConfig() {
95
+ var userJestConfig = this.userJestConfig;
96
+ if (typeof userJestConfig === "object") {
97
+ this.setJestConfig(userJestConfig);
123
98
  }
124
- ]);
125
- return TestConfigOperator;
99
+ }
100
+ },
101
+ {
102
+ key: "setJestConfig",
103
+ value: function setJestConfig(sourceConfig, options) {
104
+ if (options) {
105
+ var force = options.force;
106
+ if (force) {
107
+ this._jestConfig = sourceConfig;
108
+ return;
109
+ }
110
+ }
111
+ this._jestConfig = _object_spread({}, this._jestConfig, sourceConfig);
112
+ }
113
+ },
114
+ {
115
+ key: "getFinalConfig",
116
+ value: function getFinalConfig() {
117
+ var userJestConfig = this.userJestConfig;
118
+ if (!userJestConfig) {
119
+ return this._jestConfig;
120
+ }
121
+ if (typeof userJestConfig === "function") {
122
+ return userJestConfig(this._jestConfig);
123
+ }
124
+ return this.jestConfig;
125
+ }
126
+ }
127
+ ]);
128
+ return TestConfigOperator2;
126
129
  }();
127
130
  export { TestConfigOperator };
@@ -1,17 +1,16 @@
1
1
  var _babelJest_createTransformer;
2
2
  import babelJest from "babel-jest";
3
3
  var babelTransformer = (_babelJest_createTransformer = babelJest.createTransformer) === null || _babelJest_createTransformer === void 0 ? void 0 : _babelJest_createTransformer.call(babelJest, {
4
- presets: [
5
- [
6
- require.resolve("@modern-js/babel-preset-app"),
7
- {
8
- appDirectory: process.cwd(),
9
- modules: "cjs"
10
- }
11
- ]
12
- ],
13
- configFile: false,
14
- babelrc: false
4
+ presets: [
5
+ [
6
+ require.resolve("@modern-js/babel-preset-app"),
7
+ {
8
+ appDirectory: process.cwd(),
9
+ modules: "cjs"
10
+ }
11
+ ]
12
+ ],
13
+ configFile: false,
14
+ babelrc: false
15
15
  });
16
- var babelTransformer_default = babelTransformer;
17
- export { babelTransformer_default as default };
16
+ export default babelTransformer;
@@ -1,8 +1,7 @@
1
1
  import { createAsyncPipeline, createParallelWorkflow } from "@modern-js/plugin";
2
- var jestConfigHook = createAsyncPipeline();
3
- var afterTestHook = createParallelWorkflow();
4
- var testingHooks = {
5
- jestConfig: createAsyncPipeline(),
6
- afterTest: createParallelWorkflow()
2
+ export var jestConfigHook = createAsyncPipeline();
3
+ export var afterTestHook = createParallelWorkflow();
4
+ export var testingHooks = {
5
+ jestConfig: createAsyncPipeline(),
6
+ afterTest: createParallelWorkflow()
7
7
  };
8
- export { afterTestHook, jestConfigHook, testingHooks };
@@ -1,7 +1,6 @@
1
- import { runTest, runJest } from "./runJest";
2
- import { getModuleNameMapper } from "./utils";
3
- import { DEFAULT_RESOLVER_PATH } from "./config";
4
- import { TestConfigOperator } from "./config/testConfigOperator";
5
- import { testingHooks } from "./hook";
1
+ export { runTest, runJest } from "./runJest";
2
+ export { getModuleNameMapper } from "./utils";
3
+ export { DEFAULT_RESOLVER_PATH } from "./config";
4
+ export { TestConfigOperator } from "./config/testConfigOperator";
5
+ export { testingHooks } from "./hook";
6
6
  export * from "./types";
7
- export { DEFAULT_RESOLVER_PATH, TestConfigOperator, getModuleNameMapper, runJest, runTest, testingHooks };