@modern-js/plugin-testing 2.20.1-alpha.0 → 2.21.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/package.json +17 -17
  3. package/dist/js/modern/base/config/index.js +0 -36
  4. package/dist/js/modern/base/config/patches/assetsModule.js +0 -11
  5. package/dist/js/modern/base/config/patches/filemock.js +0 -4
  6. package/dist/js/modern/base/config/patches/index.js +0 -34
  7. package/dist/js/modern/base/config/patches/transformer.js +0 -38
  8. package/dist/js/modern/base/config/resolver.js +0 -21
  9. package/dist/js/modern/base/config/testConfigOperator.js +0 -69
  10. package/dist/js/modern/base/config/transformer/babelTransformer.js +0 -19
  11. package/dist/js/modern/base/hook.js +0 -12
  12. package/dist/js/modern/base/index.js +0 -14
  13. package/dist/js/modern/base/runJest.js +0 -102
  14. package/dist/js/modern/base/types/index.js +0 -0
  15. package/dist/js/modern/base/utils.js +0 -66
  16. package/dist/js/modern/cli/bff/app.js +0 -58
  17. package/dist/js/modern/cli/bff/constant.js +0 -4
  18. package/dist/js/modern/cli/bff/index.js +0 -149
  19. package/dist/js/modern/cli/bff/mockAPI.js +0 -109
  20. package/dist/js/modern/cli/bff/setup.js +0 -75
  21. package/dist/js/modern/cli/bff/utils/index.js +0 -37
  22. package/dist/js/modern/cli/index.js +0 -115
  23. package/dist/js/modern/cli/test.js +0 -61
  24. package/dist/js/modern/constant.js +0 -4
  25. package/dist/js/modern/index.js +0 -3
  26. package/dist/js/modern/runtime-testing/app.js +0 -48
  27. package/dist/js/modern/runtime-testing/base.js +0 -7
  28. package/dist/js/modern/runtime-testing/customRender.js +0 -25
  29. package/dist/js/modern/runtime-testing/index.js +0 -2
  30. package/dist/js/modern/runtime-testing/reduck.js +0 -55
  31. package/dist/js/modern/runtime-testing/request.js +0 -16
  32. package/dist/js/modern/runtime-testing/resolvePlugins.js +0 -33
  33. package/dist/js/node/base/config/index.js +0 -67
  34. package/dist/js/node/base/config/patches/assetsModule.js +0 -40
  35. package/dist/js/node/base/config/patches/filemock.js +0 -25
  36. package/dist/js/node/base/config/patches/index.js +0 -57
  37. package/dist/js/node/base/config/patches/transformer.js +0 -67
  38. package/dist/js/node/base/config/resolver.js +0 -30
  39. package/dist/js/node/base/config/testConfigOperator.js +0 -90
  40. package/dist/js/node/base/config/transformer/babelTransformer.js +0 -46
  41. package/dist/js/node/base/hook.js +0 -37
  42. package/dist/js/node/base/index.js +0 -43
  43. package/dist/js/node/base/runJest.js +0 -132
  44. package/dist/js/node/base/types/index.js +0 -15
  45. package/dist/js/node/base/utils.js +0 -95
  46. package/dist/js/node/cli/bff/app.js +0 -84
  47. package/dist/js/node/cli/bff/constant.js +0 -27
  48. package/dist/js/node/cli/bff/index.js +0 -173
  49. package/dist/js/node/cli/bff/mockAPI.js +0 -134
  50. package/dist/js/node/cli/bff/setup.js +0 -84
  51. package/dist/js/node/cli/bff/utils/index.js +0 -64
  52. package/dist/js/node/cli/index.js +0 -135
  53. package/dist/js/node/cli/test.js +0 -88
  54. package/dist/js/node/constant.js +0 -27
  55. package/dist/js/node/index.js +0 -19
  56. package/dist/js/node/runtime-testing/app.js +0 -73
  57. package/dist/js/node/runtime-testing/base.js +0 -38
  58. package/dist/js/node/runtime-testing/customRender.js +0 -50
  59. package/dist/js/node/runtime-testing/index.js +0 -18
  60. package/dist/js/node/runtime-testing/reduck.js +0 -85
  61. package/dist/js/node/runtime-testing/request.js +0 -45
  62. package/dist/js/node/runtime-testing/resolvePlugins.js +0 -52
  63. package/dist/js/treeshaking/base/config/index.js +0 -154
  64. package/dist/js/treeshaking/base/config/patches/assetsModule.js +0 -9
  65. package/dist/js/treeshaking/base/config/patches/filemock.js +0 -2
  66. package/dist/js/treeshaking/base/config/patches/index.js +0 -225
  67. package/dist/js/treeshaking/base/config/patches/transformer.js +0 -36
  68. package/dist/js/treeshaking/base/config/resolver.js +0 -37
  69. package/dist/js/treeshaking/base/config/testConfigOperator.js +0 -127
  70. package/dist/js/treeshaking/base/config/transformer/babelTransformer.js +0 -17
  71. package/dist/js/treeshaking/base/hook.js +0 -8
  72. package/dist/js/treeshaking/base/index.js +0 -7
  73. package/dist/js/treeshaking/base/runJest.js +0 -292
  74. package/dist/js/treeshaking/base/types/index.js +0 -1
  75. package/dist/js/treeshaking/base/utils.js +0 -76
  76. package/dist/js/treeshaking/cli/bff/app.js +0 -200
  77. package/dist/js/treeshaking/cli/bff/constant.js +0 -2
  78. package/dist/js/treeshaking/cli/bff/index.js +0 -297
  79. package/dist/js/treeshaking/cli/bff/mockAPI.js +0 -188
  80. package/dist/js/treeshaking/cli/bff/setup.js +0 -192
  81. package/dist/js/treeshaking/cli/bff/utils/index.js +0 -47
  82. package/dist/js/treeshaking/cli/index.js +0 -255
  83. package/dist/js/treeshaking/cli/test.js +0 -180
  84. package/dist/js/treeshaking/constant.js +0 -2
  85. package/dist/js/treeshaking/index.js +0 -3
  86. package/dist/js/treeshaking/runtime-testing/app.js +0 -90
  87. package/dist/js/treeshaking/runtime-testing/base.js +0 -4
  88. package/dist/js/treeshaking/runtime-testing/customRender.js +0 -41
  89. package/dist/js/treeshaking/runtime-testing/index.js +0 -2
  90. package/dist/js/treeshaking/runtime-testing/reduck.js +0 -89
  91. package/dist/js/treeshaking/runtime-testing/request.js +0 -51
  92. package/dist/js/treeshaking/runtime-testing/resolvePlugins.js +0 -46
@@ -1,192 +0,0 @@
1
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2
- try {
3
- var info = gen[key](arg);
4
- var value = info.value;
5
- } catch (error) {
6
- reject(error);
7
- return;
8
- }
9
- if (info.done) {
10
- resolve(value);
11
- } else {
12
- Promise.resolve(value).then(_next, _throw);
13
- }
14
- }
15
- function _asyncToGenerator(fn) {
16
- return function() {
17
- var self = this, args = arguments;
18
- return new Promise(function(resolve, reject) {
19
- var gen = fn.apply(self, args);
20
- function _next(value) {
21
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
22
- }
23
- function _throw(err) {
24
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
25
- }
26
- _next(undefined);
27
- });
28
- };
29
- }
30
- var __generator = this && this.__generator || function(thisArg, body) {
31
- var f, y, t, g, _ = {
32
- label: 0,
33
- sent: function() {
34
- if (t[0] & 1) throw t[1];
35
- return t[1];
36
- },
37
- trys: [],
38
- ops: []
39
- };
40
- return g = {
41
- next: verb(0),
42
- "throw": verb(1),
43
- "return": verb(2)
44
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
45
- return this;
46
- }), g;
47
- function verb(n) {
48
- return function(v) {
49
- return step([
50
- n,
51
- v
52
- ]);
53
- };
54
- }
55
- function step(op) {
56
- if (f) throw new TypeError("Generator is already executing.");
57
- while(_)try {
58
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
59
- if (y = 0, t) op = [
60
- op[0] & 2,
61
- t.value
62
- ];
63
- switch(op[0]){
64
- case 0:
65
- case 1:
66
- t = op;
67
- break;
68
- case 4:
69
- _.label++;
70
- return {
71
- value: op[1],
72
- done: false
73
- };
74
- case 5:
75
- _.label++;
76
- y = op[1];
77
- op = [
78
- 0
79
- ];
80
- continue;
81
- case 7:
82
- op = _.ops.pop();
83
- _.trys.pop();
84
- continue;
85
- default:
86
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
87
- _ = 0;
88
- continue;
89
- }
90
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
91
- _.label = op[1];
92
- break;
93
- }
94
- if (op[0] === 6 && _.label < t[1]) {
95
- _.label = t[1];
96
- t = op;
97
- break;
98
- }
99
- if (t && _.label < t[2]) {
100
- _.label = t[2];
101
- _.ops.push(op);
102
- break;
103
- }
104
- if (t[2]) _.ops.pop();
105
- _.trys.pop();
106
- continue;
107
- }
108
- op = body.call(thisArg, _);
109
- } catch (e) {
110
- op = [
111
- 6,
112
- e
113
- ];
114
- y = 0;
115
- } finally{
116
- f = t = 0;
117
- }
118
- if (op[0] & 5) throw op[1];
119
- return {
120
- value: op[0] ? op[1] : void 0,
121
- done: true
122
- };
123
- }
124
- };
125
- import path from "path";
126
- import { ApiRouter } from "@modern-js/bff-core";
127
- import { bff_info_key } from "./constant";
128
- import mockAPI from "./mockAPI";
129
- import { createApp, closeServer } from "./app";
130
- var uped = false;
131
- var setup = function() {
132
- var ref, ref1;
133
- if (uped) {
134
- return;
135
- }
136
- uped = true;
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;
139
- var apiRouter = new ApiRouter({
140
- apiDir: path.join(bff_info.appDir, "./api"),
141
- prefix: prefix
142
- });
143
- var apiInfos = apiRouter.getApiHandlers();
144
- var apiInfosByFile = apiInfos.reduce(function(res, apiInfo) {
145
- if (!res[apiInfo.filename]) {
146
- res[apiInfo.filename] = [];
147
- }
148
- res[apiInfo.filename].push(apiInfo);
149
- return res;
150
- }, {});
151
- var app = null;
152
- beforeAll(/*#__PURE__*/ _asyncToGenerator(function() {
153
- return __generator(this, function(_state) {
154
- switch(_state.label){
155
- case 0:
156
- if (!!app) return [
157
- 3,
158
- 2
159
- ];
160
- return [
161
- 4,
162
- createApp(bff_info.appDir, bff_info.modernUserConfig, bff_info.plugins, bff_info.routes)
163
- ];
164
- case 1:
165
- app = _state.sent();
166
- _state.label = 2;
167
- case 2:
168
- return [
169
- 2
170
- ];
171
- }
172
- });
173
- }));
174
- afterAll(/*#__PURE__*/ _asyncToGenerator(function() {
175
- return __generator(this, function(_state) {
176
- switch(_state.label){
177
- case 0:
178
- return [
179
- 4,
180
- closeServer()
181
- ];
182
- case 1:
183
- _state.sent();
184
- return [
185
- 2
186
- ];
187
- }
188
- });
189
- }));
190
- mockAPI(apiInfosByFile);
191
- };
192
- setup();
@@ -1,47 +0,0 @@
1
- function _defineProperty(obj, key, value) {
2
- if (key in obj) {
3
- Object.defineProperty(obj, key, {
4
- value: value,
5
- enumerable: true,
6
- configurable: true,
7
- writable: true
8
- });
9
- } else {
10
- obj[key] = value;
11
- }
12
- return obj;
13
- }
14
- function _objectSpread(target) {
15
- for(var i = 1; i < arguments.length; i++){
16
- var source = arguments[i] != null ? arguments[i] : {};
17
- var ownKeys = Object.keys(source);
18
- if (typeof Object.getOwnPropertySymbols === "function") {
19
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
20
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
21
- }));
22
- }
23
- ownKeys.forEach(function(key) {
24
- _defineProperty(target, key, source[key]);
25
- });
26
- }
27
- return target;
28
- }
29
- import path from "path";
30
- import { chalk } from "@modern-js/utils";
31
- var isBFFProject = function(pwd) {
32
- try {
33
- var packageJson = require(path.join(pwd, "./package.json"));
34
- var dependencies = packageJson.dependencies, devDependencies = packageJson.devDependencies;
35
- var isBFF = Object.keys(_objectSpread({}, dependencies, devDependencies)).some(function(dependency) {
36
- return dependency.includes("plugin-bff");
37
- });
38
- var isMWA = Object.keys(devDependencies).some(function(devDependency) {
39
- return devDependency.includes("app-tools");
40
- });
41
- return isMWA && isBFF;
42
- } catch (error) {
43
- console.log(chalk.red(error));
44
- return false;
45
- }
46
- };
47
- export { isBFFProject };
@@ -1,255 +0,0 @@
1
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2
- try {
3
- var info = gen[key](arg);
4
- var value = info.value;
5
- } catch (error) {
6
- reject(error);
7
- return;
8
- }
9
- if (info.done) {
10
- resolve(value);
11
- } else {
12
- Promise.resolve(value).then(_next, _throw);
13
- }
14
- }
15
- function _asyncToGenerator(fn) {
16
- return function() {
17
- var self = this, args = arguments;
18
- return new Promise(function(resolve, reject) {
19
- var gen = fn.apply(self, args);
20
- function _next(value) {
21
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
22
- }
23
- function _throw(err) {
24
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
25
- }
26
- _next(undefined);
27
- });
28
- };
29
- }
30
- function _defineProperty(obj, key, value) {
31
- if (key in obj) {
32
- Object.defineProperty(obj, key, {
33
- value: value,
34
- enumerable: true,
35
- configurable: true,
36
- writable: true
37
- });
38
- } else {
39
- obj[key] = value;
40
- }
41
- return obj;
42
- }
43
- var __generator = this && this.__generator || function(thisArg, body) {
44
- var f, y, t, g, _ = {
45
- label: 0,
46
- sent: function() {
47
- if (t[0] & 1) throw t[1];
48
- return t[1];
49
- },
50
- trys: [],
51
- ops: []
52
- };
53
- return(g = {
54
- next: verb(0),
55
- "throw": verb(1),
56
- "return": verb(2)
57
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
58
- return this;
59
- }), g);
60
- function verb(n) {
61
- return function(v) {
62
- return step([
63
- n,
64
- v
65
- ]);
66
- };
67
- }
68
- function step(op) {
69
- if (f) throw new TypeError("Generator is already executing.");
70
- while(_)try {
71
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
72
- if (y = 0, t) op = [
73
- op[0] & 2,
74
- t.value
75
- ];
76
- switch(op[0]){
77
- case 0:
78
- case 1:
79
- t = op;
80
- break;
81
- case 4:
82
- _.label++;
83
- return {
84
- value: op[1],
85
- done: false
86
- };
87
- case 5:
88
- _.label++;
89
- y = op[1];
90
- op = [
91
- 0
92
- ];
93
- continue;
94
- case 7:
95
- op = _.ops.pop();
96
- _.trys.pop();
97
- continue;
98
- default:
99
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
100
- _ = 0;
101
- continue;
102
- }
103
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
104
- _.label = op[1];
105
- break;
106
- }
107
- if (op[0] === 6 && _.label < t[1]) {
108
- _.label = t[1];
109
- t = op;
110
- break;
111
- }
112
- if (t && _.label < t[2]) {
113
- _.label = t[2];
114
- _.ops.push(op);
115
- break;
116
- }
117
- if (t[2]) _.ops.pop();
118
- _.trys.pop();
119
- continue;
120
- }
121
- op = body.call(thisArg, _);
122
- } catch (e) {
123
- op = [
124
- 6,
125
- e
126
- ];
127
- y = 0;
128
- } finally{
129
- f = t = 0;
130
- }
131
- if (op[0] & 5) throw op[1];
132
- return {
133
- value: op[0] ? op[1] : void 0,
134
- done: true
135
- };
136
- }
137
- };
138
- import path from "path";
139
- import { isApiOnly, mergeAlias, PLUGIN_SCHEMAS, createRuntimeExportsUtils } from "@modern-js/utils";
140
- import { testingHooks, getModuleNameMapper, DEFAULT_RESOLVER_PATH } from "../base";
141
- import { MODERNJS_CONFIG_KEY } from "../constant";
142
- import testingBffPlugin from "./bff";
143
- import test from "./test";
144
- var mergeUserJestConfig = function(testUtils) {
145
- var resolveJestConfig = testUtils.testConfig.jest;
146
- if (resolveJestConfig && typeof resolveJestConfig !== "function") {
147
- testUtils.mergeJestConfig(resolveJestConfig);
148
- }
149
- };
150
- var cli_default = function() {
151
- var bffPlugin = testingBffPlugin();
152
- return {
153
- name: "@modern-js/plugin-testing",
154
- usePlugins: [
155
- bffPlugin
156
- ],
157
- post: [
158
- bffPlugin.name
159
- ],
160
- registerHook: testingHooks,
161
- setup: function(api) {
162
- var testingExportsUtils;
163
- return {
164
- commands: function(param) {
165
- var program = param.program;
166
- program.command("test").allowUnknownOption().usage("<regexForTestFiles> --[options]").action(/*#__PURE__*/ _asyncToGenerator(function() {
167
- return __generator(this, function(_state) {
168
- switch(_state.label){
169
- case 0:
170
- return [
171
- 4,
172
- test(api)
173
- ];
174
- case 1:
175
- _state.sent();
176
- return [
177
- 2
178
- ];
179
- }
180
- });
181
- }));
182
- },
183
- validateSchema: function validateSchema() {
184
- return PLUGIN_SCHEMAS["@modern-js/plugin-testing"];
185
- },
186
- config: function config() {
187
- var appContext = api.useAppContext();
188
- testingExportsUtils = createRuntimeExportsUtils(appContext.internalDirectory, "testing");
189
- return {
190
- source: {
191
- alias: {
192
- "@": path.join(appContext.appDirectory, "src"),
193
- "@modern-js/runtime/testing": testingExportsUtils.getPath()
194
- }
195
- }
196
- };
197
- },
198
- addRuntimeExports: function addRuntimeExports() {
199
- var testingPath = path.resolve(__dirname, "../");
200
- testingExportsUtils.addExport("export * from '".concat(testingPath, "'"));
201
- },
202
- jestConfig: function() {
203
- var _ref = _asyncToGenerator(function(utils, next) {
204
- var appContext, userConfig, apiOnly, alias;
205
- return __generator(this, function(_state) {
206
- switch(_state.label){
207
- case 0:
208
- appContext = api.useAppContext();
209
- userConfig = api.useResolvedConfigContext();
210
- return [
211
- 4,
212
- isApiOnly(appContext.appDirectory)
213
- ];
214
- case 1:
215
- apiOnly = _state.sent();
216
- if (apiOnly) {
217
- return [
218
- 2,
219
- next(utils)
220
- ];
221
- }
222
- alias = mergeAlias(userConfig.source.alias);
223
- if (testingExportsUtils) {
224
- alias["@modern-js/runtime/testing"] = [
225
- testingExportsUtils.getPath()
226
- ];
227
- }
228
- utils.mergeJestConfig({
229
- globals: _defineProperty({}, MODERNJS_CONFIG_KEY, userConfig),
230
- moduleNameMapper: getModuleNameMapper(alias),
231
- testEnvironment: "jsdom",
232
- resolver: DEFAULT_RESOLVER_PATH,
233
- rootDir: appContext.appDirectory || process.cwd(),
234
- testMatch: [
235
- "<rootDir>/src/**/*.test.[jt]s?(x)",
236
- "<rootDir>/tests/**/*.test.[jt]s?(x)"
237
- ]
238
- });
239
- mergeUserJestConfig(utils);
240
- return [
241
- 2,
242
- next(utils)
243
- ];
244
- }
245
- });
246
- });
247
- return function(utils, next) {
248
- return _ref.apply(this, arguments);
249
- };
250
- }()
251
- };
252
- }
253
- };
254
- };
255
- export { cli_default as default, mergeUserJestConfig };
@@ -1,180 +0,0 @@
1
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2
- try {
3
- var info = gen[key](arg);
4
- var value = info.value;
5
- } catch (error) {
6
- reject(error);
7
- return;
8
- }
9
- if (info.done) {
10
- resolve(value);
11
- } else {
12
- Promise.resolve(value).then(_next, _throw);
13
- }
14
- }
15
- function _asyncToGenerator(fn) {
16
- return function() {
17
- var self = this, args = arguments;
18
- return new Promise(function(resolve, reject) {
19
- var gen = fn.apply(self, args);
20
- function _next(value) {
21
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
22
- }
23
- function _throw(err) {
24
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
25
- }
26
- _next(undefined);
27
- });
28
- };
29
- }
30
- var __generator = this && this.__generator || function(thisArg, body) {
31
- var f, y, t, g, _ = {
32
- label: 0,
33
- sent: function() {
34
- if (t[0] & 1) throw t[1];
35
- return t[1];
36
- },
37
- trys: [],
38
- ops: []
39
- };
40
- return(g = {
41
- next: verb(0),
42
- "throw": verb(1),
43
- "return": verb(2)
44
- }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
45
- return this;
46
- }), g);
47
- function verb(n) {
48
- return function(v) {
49
- return step([
50
- n,
51
- v
52
- ]);
53
- };
54
- }
55
- function step(op) {
56
- if (f) throw new TypeError("Generator is already executing.");
57
- while(_)try {
58
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
59
- if (y = 0, t) op = [
60
- op[0] & 2,
61
- t.value
62
- ];
63
- switch(op[0]){
64
- case 0:
65
- case 1:
66
- t = op;
67
- break;
68
- case 4:
69
- _.label++;
70
- return {
71
- value: op[1],
72
- done: false
73
- };
74
- case 5:
75
- _.label++;
76
- y = op[1];
77
- op = [
78
- 0
79
- ];
80
- continue;
81
- case 7:
82
- op = _.ops.pop();
83
- _.trys.pop();
84
- continue;
85
- default:
86
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
87
- _ = 0;
88
- continue;
89
- }
90
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
91
- _.label = op[1];
92
- break;
93
- }
94
- if (op[0] === 6 && _.label < t[1]) {
95
- _.label = t[1];
96
- t = op;
97
- break;
98
- }
99
- if (t && _.label < t[2]) {
100
- _.label = t[2];
101
- _.ops.push(op);
102
- break;
103
- }
104
- if (t[2]) _.ops.pop();
105
- _.trys.pop();
106
- continue;
107
- }
108
- op = body.call(thisArg, _);
109
- } catch (e) {
110
- op = [
111
- 6,
112
- e
113
- ];
114
- y = 0;
115
- } finally{
116
- f = t = 0;
117
- }
118
- if (op[0] & 5) throw op[1];
119
- return {
120
- value: op[0] ? op[1] : void 0,
121
- done: true
122
- };
123
- }
124
- };
125
- import path from "path";
126
- import { compiler } from "@modern-js/babel-compiler";
127
- import { runTest } from "../base";
128
- var test = function() {
129
- var _ref = _asyncToGenerator(function(api) {
130
- var ref, ref1, userConfig, appContext, jest, runtimeExportsPath;
131
- return __generator(this, function(_state) {
132
- switch(_state.label){
133
- case 0:
134
- userConfig = api.useResolvedConfigContext();
135
- appContext = api.useAppContext();
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);
138
- if (Array.isArray(jest)) {
139
- userConfig.testing.jest = jest[0];
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);
142
- runtimeExportsPath = path.join(appContext.internalDirectory, ".runtime-exports");
143
- return [
144
- 4,
145
- compiler({
146
- sourceDir: runtimeExportsPath,
147
- rootDir: runtimeExportsPath,
148
- distDir: runtimeExportsPath,
149
- quiet: true
150
- }, {
151
- presets: [
152
- [
153
- require.resolve("@babel/preset-env"),
154
- {
155
- modules: "cjs"
156
- }
157
- ]
158
- ]
159
- })
160
- ];
161
- case 1:
162
- _state.sent();
163
- return [
164
- 4,
165
- runTest(api, userConfig.testing)
166
- ];
167
- case 2:
168
- _state.sent();
169
- return [
170
- 2
171
- ];
172
- }
173
- });
174
- });
175
- return function test(api) {
176
- return _ref.apply(this, arguments);
177
- };
178
- }();
179
- var test_default = test;
180
- export { test_default as default };
@@ -1,2 +0,0 @@
1
- var MODERNJS_CONFIG_KEY = "__modernjs_config__";
2
- export { MODERNJS_CONFIG_KEY };
@@ -1,3 +0,0 @@
1
- import "@testing-library/jest-dom/extend-expect";
2
- import "@testing-library/jest-dom";
3
- export * from "./runtime-testing";