@modern-js/plugin-testing 2.0.0-beta.3 → 2.0.0-beta.6
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +159 -0
- package/dist/js/modern/base/config/index.js +29 -9
- package/dist/js/modern/base/config/patches/assetsModule.js +7 -7
- package/dist/js/modern/base/config/patches/filemock.js +4 -1
- package/dist/js/modern/base/config/patches/index.js +30 -7
- package/dist/js/modern/base/config/patches/transformer.js +13 -18
- package/dist/js/modern/base/config/resolver.js +20 -11
- package/dist/js/modern/base/config/testConfigOperator.js +29 -23
- package/dist/js/modern/base/config/transformer/babelTransformer.js +16 -8
- package/dist/js/modern/base/hook.js +10 -5
- package/dist/js/modern/base/index.js +14 -6
- package/dist/js/modern/base/runJest.js +73 -62
- package/dist/js/modern/base/utils.js +40 -23
- package/dist/js/modern/cli/bff/app.js +37 -12
- package/dist/js/modern/cli/bff/constant.js +4 -1
- package/dist/js/modern/cli/bff/index.js +95 -52
- package/dist/js/modern/cli/bff/mockAPI.js +79 -64
- package/dist/js/modern/cli/bff/setup.js +71 -34
- package/dist/js/modern/cli/bff/utils/index.js +31 -15
- package/dist/js/modern/cli/index.js +65 -30
- package/dist/js/modern/cli/test.js +53 -18
- package/dist/js/modern/constant.js +4 -1
- package/dist/js/modern/index.js +3 -3
- package/dist/js/modern/modern-app.env.d.js +0 -0
- package/dist/js/modern/runtime-testing/app.js +25 -14
- package/dist/js/modern/runtime-testing/base.js +7 -3
- package/dist/js/modern/runtime-testing/customRender.js +24 -10
- package/dist/js/modern/runtime-testing/index.js +1 -1
- package/dist/js/modern/runtime-testing/reduck.js +41 -19
- package/dist/js/modern/runtime-testing/request.js +4 -4
- package/dist/js/modern/runtime-testing/resolvePlugins.js +24 -8
- package/dist/js/node/base/config/index.js +62 -18
- package/dist/js/node/base/config/patches/assetsModule.js +34 -12
- package/dist/js/node/base/config/patches/filemock.js +24 -7
- package/dist/js/node/base/config/patches/index.js +54 -15
- package/dist/js/node/base/config/patches/transformer.js +42 -25
- package/dist/js/node/base/config/resolver.js +25 -10
- package/dist/js/node/base/config/testConfigOperator.js +51 -30
- package/dist/js/node/base/config/transformer/babelTransformer.js +42 -15
- package/dist/js/node/base/hook.js +34 -13
- package/dist/js/node/base/index.js +39 -62
- package/dist/js/node/base/runJest.js +104 -71
- package/dist/js/node/base/types/index.js +15 -0
- package/dist/js/node/base/utils.js +70 -34
- package/dist/js/node/cli/bff/app.js +64 -22
- package/dist/js/node/cli/bff/constant.js +26 -7
- package/dist/js/node/cli/bff/index.js +123 -65
- package/dist/js/node/cli/bff/mockAPI.js +103 -71
- package/dist/js/node/cli/bff/setup.js +71 -28
- package/dist/js/node/cli/bff/utils/index.js +57 -22
- package/dist/js/node/cli/index.js +92 -46
- package/dist/js/node/cli/test.js +81 -27
- package/dist/js/node/constant.js +26 -7
- package/dist/js/node/index.js +19 -18
- package/dist/js/node/modern-app.env.d.js +0 -0
- package/dist/js/node/runtime-testing/app.js +53 -25
- package/dist/js/node/runtime-testing/base.js +34 -32
- package/dist/js/node/runtime-testing/customRender.js +49 -18
- package/dist/js/node/runtime-testing/index.js +18 -27
- package/dist/js/node/runtime-testing/reduck.js +72 -31
- package/dist/js/node/runtime-testing/request.js +36 -13
- package/dist/js/node/runtime-testing/resolvePlugins.js +41 -12
- package/dist/js/treeshaking/base/config/index.js +150 -31
- package/dist/js/treeshaking/base/config/patches/assetsModule.js +9 -11
- package/dist/js/treeshaking/base/config/patches/filemock.js +2 -1
- package/dist/js/treeshaking/base/config/patches/index.js +221 -64
- package/dist/js/treeshaking/base/config/patches/transformer.js +34 -37
- package/dist/js/treeshaking/base/config/resolver.js +36 -13
- package/dist/js/treeshaking/base/config/testConfigOperator.js +120 -69
- package/dist/js/treeshaking/base/config/transformer/babelTransformer.js +16 -10
- package/dist/js/treeshaking/base/hook.js +8 -7
- package/dist/js/treeshaking/base/index.js +7 -6
- package/dist/js/treeshaking/base/runJest.js +281 -164
- package/dist/js/treeshaking/base/types/index.js +1 -0
- package/dist/js/treeshaking/base/utils.js +72 -48
- package/dist/js/treeshaking/cli/bff/app.js +192 -68
- package/dist/js/treeshaking/cli/bff/constant.js +2 -1
- package/dist/js/treeshaking/cli/bff/index.js +291 -130
- package/dist/js/treeshaking/cli/bff/mockAPI.js +181 -91
- package/dist/js/treeshaking/cli/bff/setup.js +185 -59
- package/dist/js/treeshaking/cli/bff/utils/index.js +47 -21
- package/dist/js/treeshaking/cli/index.js +249 -108
- package/dist/js/treeshaking/cli/test.js +177 -44
- package/dist/js/treeshaking/constant.js +2 -1
- package/dist/js/treeshaking/index.js +3 -3
- package/dist/js/treeshaking/modern-app.env.d.js +1 -0
- package/dist/js/treeshaking/runtime-testing/app.js +85 -39
- package/dist/js/treeshaking/runtime-testing/base.js +4 -3
- package/dist/js/treeshaking/runtime-testing/customRender.js +38 -10
- package/dist/js/treeshaking/runtime-testing/index.js +1 -1
- package/dist/js/treeshaking/runtime-testing/reduck.js +85 -33
- package/dist/js/treeshaking/runtime-testing/request.js +49 -19
- package/dist/js/treeshaking/runtime-testing/resolvePlugins.js +45 -14
- package/dist/types/base/config/index.d.ts +1 -0
- package/dist/types/base/config/patches/assetsModule.d.ts +1 -0
- package/dist/types/base/config/patches/filemock.d.ts +1 -0
- package/dist/types/base/config/patches/transformer.d.ts +1 -0
- package/dist/types/base/config/testConfigOperator.d.ts +2 -0
- package/dist/types/base/runJest.d.ts +2 -0
- package/dist/types/base/utils.d.ts +1 -0
- package/dist/types/cli/bff/index.d.ts +2 -0
- package/dist/types/cli/bff/mockAPI.d.ts +1 -0
- package/dist/types/cli/index.d.ts +2 -0
- package/dist/types/runtime-testing/app.d.ts +3 -0
- package/dist/types/runtime-testing/customRender.d.ts +2 -0
- package/package.json +21 -25
@@ -1,114 +1,255 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
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
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
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
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
return
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
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
|
+
});
|
96
246
|
});
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
function jestConfig(_x, _x2) {
|
107
|
-
return _jestConfig.apply(this, arguments);
|
108
|
-
}
|
109
|
-
return jestConfig;
|
110
|
-
}()
|
111
|
-
};
|
112
|
-
}
|
113
|
-
};
|
114
|
-
});
|
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,47 +1,180 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
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
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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
|
-
|
179
|
+
var test_default = test;
|
180
|
+
export { test_default as default };
|
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
var MODERNJS_CONFIG_KEY = "__modernjs_config__";
|
2
|
+
export { MODERNJS_CONFIG_KEY };
|
@@ -1,3 +1,3 @@
|
|
1
|
-
import
|
2
|
-
import
|
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";
|