@modern-js/plugin-testing 2.0.0-beta.2 → 2.0.0-beta.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. package/CHANGELOG.md +145 -0
  2. package/dist/js/modern/base/config/index.js +29 -9
  3. package/dist/js/modern/base/config/patches/assetsModule.js +7 -7
  4. package/dist/js/modern/base/config/patches/filemock.js +4 -1
  5. package/dist/js/modern/base/config/patches/index.js +30 -7
  6. package/dist/js/modern/base/config/patches/transformer.js +13 -18
  7. package/dist/js/modern/base/config/resolver.js +11 -6
  8. package/dist/js/modern/base/config/testConfigOperator.js +29 -23
  9. package/dist/js/modern/base/config/transformer/babelTransformer.js +16 -8
  10. package/dist/js/modern/base/hook.js +10 -5
  11. package/dist/js/modern/base/index.js +14 -6
  12. package/dist/js/modern/base/runJest.js +73 -62
  13. package/dist/js/modern/base/utils.js +40 -23
  14. package/dist/js/modern/cli/bff/app.js +37 -12
  15. package/dist/js/modern/cli/bff/constant.js +4 -1
  16. package/dist/js/modern/cli/bff/index.js +95 -52
  17. package/dist/js/modern/cli/bff/mockAPI.js +79 -64
  18. package/dist/js/modern/cli/bff/setup.js +71 -34
  19. package/dist/js/modern/cli/bff/utils/index.js +31 -15
  20. package/dist/js/modern/cli/index.js +64 -30
  21. package/dist/js/modern/cli/test.js +53 -18
  22. package/dist/js/modern/constant.js +4 -1
  23. package/dist/js/modern/index.js +3 -3
  24. package/dist/js/modern/modern-app.env.d.js +0 -0
  25. package/dist/js/modern/runtime-testing/app.js +25 -14
  26. package/dist/js/modern/runtime-testing/base.js +7 -3
  27. package/dist/js/modern/runtime-testing/customRender.js +24 -10
  28. package/dist/js/modern/runtime-testing/index.js +1 -1
  29. package/dist/js/modern/runtime-testing/reduck.js +41 -19
  30. package/dist/js/modern/runtime-testing/request.js +4 -4
  31. package/dist/js/modern/runtime-testing/resolvePlugins.js +24 -8
  32. package/dist/js/node/base/config/index.js +56 -18
  33. package/dist/js/node/base/config/patches/assetsModule.js +30 -12
  34. package/dist/js/node/base/config/patches/filemock.js +22 -7
  35. package/dist/js/node/base/config/patches/index.js +50 -15
  36. package/dist/js/node/base/config/patches/transformer.js +38 -25
  37. package/dist/js/node/base/config/resolver.js +37 -10
  38. package/dist/js/node/base/config/testConfigOperator.js +49 -30
  39. package/dist/js/node/base/config/transformer/babelTransformer.js +40 -15
  40. package/dist/js/node/base/hook.js +28 -13
  41. package/dist/js/node/base/index.js +31 -63
  42. package/dist/js/node/base/runJest.js +99 -71
  43. package/dist/js/node/base/utils.js +66 -34
  44. package/dist/js/node/cli/bff/app.js +57 -22
  45. package/dist/js/node/cli/bff/constant.js +22 -7
  46. package/dist/js/node/cli/bff/index.js +121 -65
  47. package/dist/js/node/cli/bff/mockAPI.js +103 -71
  48. package/dist/js/node/cli/bff/setup.js +100 -38
  49. package/dist/js/node/cli/bff/utils/index.js +55 -22
  50. package/dist/js/node/cli/index.js +87 -46
  51. package/dist/js/node/cli/test.js +79 -27
  52. package/dist/js/node/constant.js +22 -7
  53. package/dist/js/node/index.js +19 -18
  54. package/dist/js/node/modern-app.env.d.js +0 -0
  55. package/dist/js/node/runtime-testing/app.js +53 -25
  56. package/dist/js/node/runtime-testing/base.js +30 -33
  57. package/dist/js/node/runtime-testing/customRender.js +49 -18
  58. package/dist/js/node/runtime-testing/index.js +18 -27
  59. package/dist/js/node/runtime-testing/reduck.js +67 -31
  60. package/dist/js/node/runtime-testing/request.js +32 -13
  61. package/dist/js/node/runtime-testing/resolvePlugins.js +41 -12
  62. package/dist/js/treeshaking/base/config/index.js +150 -31
  63. package/dist/js/treeshaking/base/config/patches/assetsModule.js +9 -11
  64. package/dist/js/treeshaking/base/config/patches/filemock.js +2 -1
  65. package/dist/js/treeshaking/base/config/patches/index.js +221 -64
  66. package/dist/js/treeshaking/base/config/patches/transformer.js +34 -37
  67. package/dist/js/treeshaking/base/config/resolver.js +24 -11
  68. package/dist/js/treeshaking/base/config/testConfigOperator.js +120 -69
  69. package/dist/js/treeshaking/base/config/transformer/babelTransformer.js +16 -10
  70. package/dist/js/treeshaking/base/hook.js +8 -7
  71. package/dist/js/treeshaking/base/index.js +7 -6
  72. package/dist/js/treeshaking/base/runJest.js +281 -164
  73. package/dist/js/treeshaking/base/types/index.js +1 -0
  74. package/dist/js/treeshaking/base/utils.js +72 -48
  75. package/dist/js/treeshaking/cli/bff/app.js +192 -68
  76. package/dist/js/treeshaking/cli/bff/constant.js +2 -1
  77. package/dist/js/treeshaking/cli/bff/index.js +291 -130
  78. package/dist/js/treeshaking/cli/bff/mockAPI.js +181 -91
  79. package/dist/js/treeshaking/cli/bff/setup.js +185 -59
  80. package/dist/js/treeshaking/cli/bff/utils/index.js +47 -21
  81. package/dist/js/treeshaking/cli/index.js +248 -108
  82. package/dist/js/treeshaking/cli/test.js +177 -44
  83. package/dist/js/treeshaking/constant.js +2 -1
  84. package/dist/js/treeshaking/index.js +3 -3
  85. package/dist/js/treeshaking/modern-app.env.d.js +1 -0
  86. package/dist/js/treeshaking/runtime-testing/app.js +85 -39
  87. package/dist/js/treeshaking/runtime-testing/base.js +4 -3
  88. package/dist/js/treeshaking/runtime-testing/customRender.js +38 -10
  89. package/dist/js/treeshaking/runtime-testing/index.js +1 -1
  90. package/dist/js/treeshaking/runtime-testing/reduck.js +85 -33
  91. package/dist/js/treeshaking/runtime-testing/request.js +49 -19
  92. package/dist/js/treeshaking/runtime-testing/resolvePlugins.js +45 -14
  93. package/dist/types/base/config/index.d.ts +1 -0
  94. package/dist/types/base/config/patches/assetsModule.d.ts +1 -0
  95. package/dist/types/base/config/patches/filemock.d.ts +1 -0
  96. package/dist/types/base/config/patches/transformer.d.ts +1 -0
  97. package/dist/types/base/config/resolver.d.ts +2 -1
  98. package/dist/types/base/config/testConfigOperator.d.ts +2 -0
  99. package/dist/types/base/runJest.d.ts +2 -0
  100. package/dist/types/base/utils.d.ts +1 -0
  101. package/dist/types/cli/bff/index.d.ts +2 -0
  102. package/dist/types/cli/bff/mockAPI.d.ts +1 -0
  103. package/dist/types/cli/index.d.ts +2 -0
  104. package/dist/types/runtime-testing/app.d.ts +3 -0
  105. package/dist/types/runtime-testing/customRender.d.ts +2 -0
  106. package/package.json +13 -13
@@ -1,114 +1,254 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
3
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
4
- import path from 'path';
5
- import { isApiOnly, mergeAlias, PLUGIN_SCHEMAS, createRuntimeExportsUtils } from '@modern-js/utils';
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";
6
140
  import { testingHooks, getModuleNameMapper, DEFAULT_RESOLVER_PATH } from "../base";
7
141
  import { MODERNJS_CONFIG_KEY } from "../constant";
8
142
  import TestingBffPlugin from "./bff";
9
143
  import test from "./test";
10
- export var mergeUserJestConfig = function mergeUserJestConfig(testUtils) {
11
- var resolveJestConfig = testUtils.testConfig.jest;
12
-
13
- // resolveJestConfig 如果是函数类型,在所有测试插件 jestConfig 都执行后,再执行生成最终配置
14
- if (resolveJestConfig && typeof resolveJestConfig !== 'function') {
15
- testUtils.mergeJestConfig(resolveJestConfig);
16
- }
144
+ var mergeUserJestConfig = function(testUtils) {
145
+ var resolveJestConfig = testUtils.testConfig.jest;
146
+ if (resolveJestConfig && typeof resolveJestConfig !== "function") {
147
+ testUtils.mergeJestConfig(resolveJestConfig);
148
+ }
17
149
  };
18
- export default (function () {
19
- var BffPlugin = TestingBffPlugin();
20
- return {
21
- name: '@modern-js/plugin-testing',
22
- usePlugins: [BffPlugin],
23
- post: [BffPlugin.name],
24
- registerHook: testingHooks,
25
- setup: function setup(api) {
26
- var testingExportsUtils;
27
- return {
28
- commands: function commands(_ref) {
29
- var program = _ref.program;
30
- program.command('test').allowUnknownOption().usage('<regexForTestFiles> --[options]').action( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
31
- return _regeneratorRuntime().wrap(function _callee$(_context) {
32
- while (1) {
33
- switch (_context.prev = _context.next) {
34
- case 0:
35
- _context.next = 2;
36
- return test(api);
37
- case 2:
38
- case "end":
39
- return _context.stop();
40
- }
41
- }
42
- }, _callee);
43
- })));
44
- },
45
- validateSchema: function validateSchema() {
46
- return PLUGIN_SCHEMAS['@modern-js/plugin-testing'];
47
- },
48
- config: function config() {
49
- var appContext = api.useAppContext();
50
- testingExportsUtils = createRuntimeExportsUtils(appContext.internalDirectory, 'testing');
51
- return {
52
- source: {
53
- alias: {
54
- '@modern-js/runtime/testing': testingExportsUtils.getPath()
55
- }
56
- }
57
- };
58
- },
59
- addRuntimeExports: function addRuntimeExports() {
60
- var testingPath = path.resolve(__dirname, '../');
61
- testingExportsUtils.addExport("export * from '".concat(testingPath, "'"));
62
- },
63
- jestConfig: function () {
64
- var _jestConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(utils, next) {
65
- var appContext, userConfig, apiOnly, alias;
66
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
67
- while (1) {
68
- switch (_context2.prev = _context2.next) {
69
- case 0:
70
- appContext = api.useAppContext();
71
- userConfig = api.useResolvedConfigContext();
72
- _context2.next = 4;
73
- return isApiOnly(appContext.appDirectory);
74
- case 4:
75
- apiOnly = _context2.sent;
76
- if (!apiOnly) {
77
- _context2.next = 7;
78
- break;
79
- }
80
- return _context2.abrupt("return", next(utils));
81
- case 7:
82
- alias = mergeAlias(userConfig.source.alias);
83
- if (testingExportsUtils) {
84
- alias['@modern-js/runtime/testing'] = [testingExportsUtils.getPath()];
85
- }
86
- utils.mergeJestConfig({
87
- globals: _defineProperty({}, MODERNJS_CONFIG_KEY, userConfig),
88
- moduleNameMapper: getModuleNameMapper(alias),
89
- testEnvironment: 'jsdom',
90
- resolver: DEFAULT_RESOLVER_PATH,
91
- rootDir: appContext.appDirectory || process.cwd(),
92
- // todo: diffrernt test root for diffrent solutions
93
- // testMatch: [`<rootDir>/(src|tests|electron)/**/*.test.[jt]s?(x)`],
94
- // testMatch bug on windows, issue: https://github.com/facebook/jest/issues/7914
95
- testMatch: ["<rootDir>/src/**/*.test.[jt]s?(x)", "<rootDir>/tests/**/*.test.[jt]s?(x)", "<rootDir>/electron/**/*.test.[jt]s?(x)"]
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
+ "@modern-js/runtime/testing": testingExportsUtils.getPath()
193
+ }
194
+ }
195
+ };
196
+ },
197
+ addRuntimeExports: function addRuntimeExports() {
198
+ var testingPath = path.resolve(__dirname, "../");
199
+ testingExportsUtils.addExport("export * from '".concat(testingPath, "'"));
200
+ },
201
+ jestConfig: function() {
202
+ var _ref = _asyncToGenerator(function(utils, next) {
203
+ var appContext, userConfig, apiOnly, alias;
204
+ return __generator(this, function(_state) {
205
+ switch(_state.label){
206
+ case 0:
207
+ appContext = api.useAppContext();
208
+ userConfig = api.useResolvedConfigContext();
209
+ return [
210
+ 4,
211
+ isApiOnly(appContext.appDirectory)
212
+ ];
213
+ case 1:
214
+ apiOnly = _state.sent();
215
+ if (apiOnly) {
216
+ return [
217
+ 2,
218
+ next(utils)
219
+ ];
220
+ }
221
+ alias = mergeAlias(userConfig.source.alias);
222
+ if (testingExportsUtils) {
223
+ alias["@modern-js/runtime/testing"] = [
224
+ testingExportsUtils.getPath()
225
+ ];
226
+ }
227
+ utils.mergeJestConfig({
228
+ globals: _defineProperty({}, MODERNJS_CONFIG_KEY, userConfig),
229
+ moduleNameMapper: getModuleNameMapper(alias),
230
+ testEnvironment: "jsdom",
231
+ resolver: DEFAULT_RESOLVER_PATH,
232
+ rootDir: appContext.appDirectory || process.cwd(),
233
+ testMatch: [
234
+ "<rootDir>/src/**/*.test.[jt]s?(x)",
235
+ "<rootDir>/tests/**/*.test.[jt]s?(x)"
236
+ ]
237
+ });
238
+ mergeUserJestConfig(utils);
239
+ return [
240
+ 2,
241
+ next(utils)
242
+ ];
243
+ }
244
+ });
96
245
  });
97
- mergeUserJestConfig(utils);
98
- return _context2.abrupt("return", next(utils));
99
- case 12:
100
- case "end":
101
- return _context2.stop();
102
- }
103
- }
104
- }, _callee2);
105
- }));
106
- function jestConfig(_x, _x2) {
107
- return _jestConfig.apply(this, arguments);
108
- }
109
- return jestConfig;
110
- }()
111
- };
112
- }
113
- };
114
- });
246
+ return function(utils, next) {
247
+ return _ref.apply(this, arguments);
248
+ };
249
+ }()
250
+ };
251
+ }
252
+ };
253
+ };
254
+ export { cli_default as default, mergeUserJestConfig };
@@ -1,47 +1,180 @@
1
- import _regeneratorRuntime from "@babel/runtime/helpers/esm/regeneratorRuntime";
2
- import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
3
- import path from 'path';
4
- import { compiler } from '@modern-js/babel-compiler';
5
- import { runTest } from "../base";
6
- var test = /*#__PURE__*/function () {
7
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(api) {
8
- var userConfig, appContext, jest, runtimeExportsPath;
9
- return _regeneratorRuntime().wrap(function _callee$(_context) {
10
- while (1) {
11
- switch (_context.prev = _context.next) {
12
- case 0:
13
- userConfig = api.useResolvedConfigContext();
14
- appContext = api.useAppContext();
15
- userConfig.testing = userConfig.testing || {};
16
- jest = userConfig.testing.jest || userConfig.tools.jest;
17
- if (Array.isArray(jest)) {
18
- userConfig.testing.jest = jest[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;
19
107
  }
20
- userConfig.testing.jest = userConfig.testing.jest || userConfig.tools.jest;
21
- runtimeExportsPath = path.join(appContext.internalDirectory, '.runtime-exports');
22
- _context.next = 9;
23
- return compiler({
24
- sourceDir: runtimeExportsPath,
25
- rootDir: runtimeExportsPath,
26
- distDir: runtimeExportsPath,
27
- quiet: true
28
- }, {
29
- presets: [[require.resolve('@babel/preset-env'), {
30
- modules: 'cjs'
31
- }]]
32
- });
33
- case 9:
34
- _context.next = 11;
35
- return runTest(api, userConfig.testing);
36
- case 11:
37
- case "end":
38
- return _context.stop();
108
+ op = body.call(thisArg, _);
109
+ } catch (e) {
110
+ op = [
111
+ 6,
112
+ e
113
+ ];
114
+ y = 0;
115
+ } finally{
116
+ f = t = 0;
39
117
  }
40
- }
41
- }, _callee);
42
- }));
43
- return function test(_x) {
44
- return _ref.apply(this, arguments);
45
- };
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
+ };
46
178
  }();
47
- export default test;
179
+ var test_default = test;
180
+ export { test_default as default };
@@ -1 +1,2 @@
1
- export var MODERNJS_CONFIG_KEY = '__modernjs_config__';
1
+ var MODERNJS_CONFIG_KEY = "__modernjs_config__";
2
+ export { MODERNJS_CONFIG_KEY };
@@ -1,3 +1,3 @@
1
- import '@testing-library/jest-dom/extend-expect';
2
- import '@testing-library/jest-dom';
3
- export * from "./runtime-testing";
1
+ import "@testing-library/jest-dom/extend-expect";
2
+ import "@testing-library/jest-dom";
3
+ export * from "./runtime-testing";
@@ -0,0 +1 @@
1
+ "use strict";