@modern-js/plugin-testing 2.0.0-beta.3 → 2.0.0-beta.4
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +77 -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 +11 -6
- 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 +64 -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 +56 -18
- package/dist/js/node/base/config/patches/assetsModule.js +30 -12
- package/dist/js/node/base/config/patches/filemock.js +22 -7
- package/dist/js/node/base/config/patches/index.js +50 -15
- package/dist/js/node/base/config/patches/transformer.js +38 -25
- package/dist/js/node/base/config/resolver.js +37 -10
- package/dist/js/node/base/config/testConfigOperator.js +49 -30
- package/dist/js/node/base/config/transformer/babelTransformer.js +40 -15
- package/dist/js/node/base/hook.js +28 -13
- package/dist/js/node/base/index.js +31 -63
- package/dist/js/node/base/runJest.js +99 -71
- package/dist/js/node/base/utils.js +66 -34
- package/dist/js/node/cli/bff/app.js +57 -22
- package/dist/js/node/cli/bff/constant.js +22 -7
- package/dist/js/node/cli/bff/index.js +121 -65
- package/dist/js/node/cli/bff/mockAPI.js +103 -71
- package/dist/js/node/cli/bff/setup.js +100 -38
- package/dist/js/node/cli/bff/utils/index.js +55 -22
- package/dist/js/node/cli/index.js +87 -46
- package/dist/js/node/cli/test.js +79 -27
- package/dist/js/node/constant.js +22 -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 +30 -33
- 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 +67 -31
- package/dist/js/node/runtime-testing/request.js +32 -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 +24 -11
- 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 +248 -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/resolver.d.ts +2 -1
- 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 +13 -13
@@ -1,76 +1,200 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
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 { AsyncLocalStorage } from "async_hooks";
|
126
|
+
import { Server } from "@modern-js/prod-server";
|
5
127
|
var store = new AsyncLocalStorage();
|
6
|
-
|
7
|
-
|
128
|
+
var isInHandler = function() {
|
129
|
+
return Boolean(store.getStore());
|
8
130
|
};
|
9
131
|
var server = null;
|
10
|
-
var createApp =
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
132
|
+
var createApp = function() {
|
133
|
+
var _ref = _asyncToGenerator(function(pwd, config, plugins, routes) {
|
134
|
+
var app;
|
135
|
+
return __generator(this, function(_state) {
|
136
|
+
switch(_state.label){
|
137
|
+
case 0:
|
138
|
+
if (!!server) return [
|
139
|
+
3,
|
140
|
+
2
|
141
|
+
];
|
142
|
+
config.output.path = "./";
|
143
|
+
server = new Server({
|
144
|
+
apiOnly: true,
|
145
|
+
pwd: pwd,
|
146
|
+
config: config,
|
147
|
+
internalPlugins: plugins,
|
148
|
+
routes: routes
|
149
|
+
});
|
150
|
+
return [
|
151
|
+
4,
|
152
|
+
server.init()
|
153
|
+
];
|
154
|
+
case 1:
|
155
|
+
_state.sent();
|
156
|
+
_state.label = 2;
|
157
|
+
case 2:
|
158
|
+
app = server.getRequestHandler();
|
159
|
+
return [
|
160
|
+
2,
|
161
|
+
app
|
162
|
+
];
|
20
163
|
}
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
internalPlugins: plugins,
|
27
|
-
routes: routes
|
28
|
-
});
|
29
|
-
_context.next = 5;
|
30
|
-
return server.init();
|
31
|
-
case 5:
|
32
|
-
app = server.getRequestHandler();
|
33
|
-
return _context.abrupt("return", app);
|
34
|
-
case 7:
|
35
|
-
case "end":
|
36
|
-
return _context.stop();
|
37
|
-
}
|
38
|
-
}
|
39
|
-
}, _callee);
|
40
|
-
}));
|
41
|
-
return function createApp(_x, _x2, _x3, _x4) {
|
42
|
-
return _ref.apply(this, arguments);
|
43
|
-
};
|
164
|
+
});
|
165
|
+
});
|
166
|
+
return function createApp(pwd, config, plugins, routes) {
|
167
|
+
return _ref.apply(this, arguments);
|
168
|
+
};
|
44
169
|
}();
|
45
|
-
var getApp = function
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
170
|
+
var getApp = function() {
|
171
|
+
if (!server) {
|
172
|
+
throw new Error("please createApp first");
|
173
|
+
}
|
174
|
+
return server.getRequestHandler();
|
50
175
|
};
|
51
|
-
var closeServer =
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
176
|
+
var closeServer = function() {
|
177
|
+
var _ref = _asyncToGenerator(function() {
|
178
|
+
return __generator(this, function(_state) {
|
179
|
+
switch(_state.label){
|
180
|
+
case 0:
|
181
|
+
if (!server) {
|
182
|
+
throw new Error("please createApp first");
|
183
|
+
}
|
184
|
+
return [
|
185
|
+
4,
|
186
|
+
server.close()
|
187
|
+
];
|
188
|
+
case 1:
|
189
|
+
_state.sent();
|
190
|
+
return [
|
191
|
+
2
|
192
|
+
];
|
60
193
|
}
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
case "end":
|
67
|
-
return _context2.stop();
|
68
|
-
}
|
69
|
-
}
|
70
|
-
}, _callee2);
|
71
|
-
}));
|
72
|
-
return function closeServer() {
|
73
|
-
return _ref2.apply(this, arguments);
|
74
|
-
};
|
194
|
+
});
|
195
|
+
});
|
196
|
+
return function closeServer() {
|
197
|
+
return _ref.apply(this, arguments);
|
198
|
+
};
|
75
199
|
}();
|
76
|
-
export { createApp, getApp,
|
200
|
+
export { closeServer, createApp, getApp, isInHandler };
|
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
var bff_info_key = "modern_bff_info";
|
2
|
+
export { bff_info_key };
|