@modern-js/plugin-testing 2.0.0-beta.3 → 2.0.0-beta.6
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.
- 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,44 +1,90 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
function _classCallCheck(instance, Constructor) {
|
|
2
|
+
if (!(instance instanceof Constructor)) {
|
|
3
|
+
throw new TypeError("Cannot call a class as a function");
|
|
4
|
+
}
|
|
5
|
+
}
|
|
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
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
16
|
+
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
17
|
+
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
18
|
+
return Constructor;
|
|
19
|
+
}
|
|
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;
|
|
32
|
+
}
|
|
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
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return target;
|
|
47
|
+
}
|
|
48
|
+
import { createApp } from "@modern-js/runtime";
|
|
6
49
|
import { MODERNJS_CONFIG_KEY } from "../constant";
|
|
7
50
|
import resolvePlugins from "./resolvePlugins";
|
|
8
|
-
var ModernRuntime = /*#__PURE__*/function
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
_createClass(ModernRuntime, [{
|
|
15
|
-
key: "init",
|
|
16
|
-
value: function init(options) {
|
|
17
|
-
this.options = options;
|
|
51
|
+
var ModernRuntime = /*#__PURE__*/ function() {
|
|
52
|
+
"use strict";
|
|
53
|
+
function ModernRuntime(options) {
|
|
54
|
+
_classCallCheck(this, ModernRuntime);
|
|
55
|
+
_defineProperty(this, "options", void 0);
|
|
56
|
+
this.options = options;
|
|
18
57
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
58
|
+
_createClass(ModernRuntime, [
|
|
59
|
+
{
|
|
60
|
+
key: "init",
|
|
61
|
+
value: function init(options) {
|
|
62
|
+
this.options = options;
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
key: "createApp",
|
|
67
|
+
value: function createApp1(props) {
|
|
68
|
+
var ref;
|
|
69
|
+
var ref1 = props || {}, entry = ref1.entry, children = ref1.children;
|
|
70
|
+
var runtimeFeatures = (ref = this.options) === null || ref === void 0 ? void 0 : ref.runtime;
|
|
71
|
+
if (entry) {
|
|
72
|
+
var ref2;
|
|
73
|
+
runtimeFeatures = _objectSpread({}, runtimeFeatures || {}, (ref2 = this.options.runtimeByEntries) === null || ref2 === void 0 ? void 0 : ref2[entry]);
|
|
74
|
+
}
|
|
75
|
+
var Component = function() {
|
|
76
|
+
if (!children) {
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
return children;
|
|
80
|
+
};
|
|
81
|
+
return createApp({
|
|
82
|
+
plugins: resolvePlugins(runtimeFeatures || {})
|
|
83
|
+
})(Component);
|
|
84
|
+
}
|
|
34
85
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return _createApp({
|
|
38
|
-
plugins: resolvePlugins(runtimeFeatures || {})
|
|
39
|
-
})(Component);
|
|
40
|
-
}
|
|
41
|
-
}]);
|
|
42
|
-
return ModernRuntime;
|
|
86
|
+
]);
|
|
87
|
+
return ModernRuntime;
|
|
43
88
|
}();
|
|
44
|
-
|
|
89
|
+
var app_default = new ModernRuntime(global[MODERNJS_CONFIG_KEY] || {});
|
|
90
|
+
export { app_default as default };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export * from
|
|
3
|
-
|
|
1
|
+
import { default as default2 } from "./customRender";
|
|
2
|
+
export * from "@testing-library/react";
|
|
3
|
+
import { request } from "./request";
|
|
4
|
+
export { default2 as renderApp, request as testBff };
|
|
@@ -1,13 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 React from "react";
|
|
30
|
+
import { render } from "@testing-library/react";
|
|
4
31
|
import app from "./app";
|
|
5
|
-
var WrapModernProviders = function
|
|
6
|
-
|
|
32
|
+
var WrapModernProviders = function(props) {
|
|
33
|
+
return React.createElement(app.createApp(props));
|
|
7
34
|
};
|
|
8
|
-
var customRender = function
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
35
|
+
var customRender = function(ui, options) {
|
|
36
|
+
return render(ui, _objectSpread({
|
|
37
|
+
wrapper: WrapModernProviders
|
|
38
|
+
}, options));
|
|
12
39
|
};
|
|
13
|
-
|
|
40
|
+
var customRender_default = customRender;
|
|
41
|
+
export { customRender_default as default };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from "./base";
|
|
2
|
-
export * from "./reduck";
|
|
2
|
+
export * from "./reduck";
|
|
@@ -1,37 +1,89 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
+
function ownKeys(object, enumerableOnly) {
|
|
30
|
+
var keys = Object.keys(object);
|
|
31
|
+
if (Object.getOwnPropertySymbols) {
|
|
32
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
33
|
+
if (enumerableOnly) {
|
|
34
|
+
symbols = symbols.filter(function(sym) {
|
|
35
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
keys.push.apply(keys, symbols);
|
|
39
|
+
}
|
|
40
|
+
return keys;
|
|
41
|
+
}
|
|
42
|
+
function _objectSpreadProps(target, source) {
|
|
43
|
+
source = source != null ? source : {};
|
|
44
|
+
if (Object.getOwnPropertyDescriptors) {
|
|
45
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
46
|
+
} else {
|
|
47
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
48
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return target;
|
|
52
|
+
}
|
|
53
|
+
import { createStore as originCreateStore } from "@modern-js-reduck/store";
|
|
54
|
+
import effectsPlugin from "@modern-js-reduck/plugin-effects";
|
|
55
|
+
import autoActionsPlugin from "@modern-js-reduck/plugin-auto-actions";
|
|
56
|
+
import immerPlugin from "@modern-js-reduck/plugin-immutable";
|
|
6
57
|
import { MODERNJS_CONFIG_KEY } from "../constant";
|
|
7
|
-
|
|
8
|
-
|
|
58
|
+
var effects = function() {
|
|
59
|
+
return effectsPlugin;
|
|
9
60
|
};
|
|
10
|
-
|
|
11
|
-
|
|
61
|
+
var immer = function() {
|
|
62
|
+
return immerPlugin;
|
|
12
63
|
};
|
|
13
|
-
|
|
14
|
-
|
|
64
|
+
var autoActions = function() {
|
|
65
|
+
return autoActionsPlugin;
|
|
15
66
|
};
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
};
|
|
67
|
+
var createStore = function(props) {
|
|
68
|
+
var createStatePlugins = function() {
|
|
69
|
+
var ref;
|
|
70
|
+
var modernConfig = global[MODERNJS_CONFIG_KEY];
|
|
71
|
+
var stateConfig = modernConfig === null || modernConfig === void 0 ? void 0 : (ref = modernConfig.runtime) === null || ref === void 0 ? void 0 : ref.state;
|
|
72
|
+
var plugins = [];
|
|
73
|
+
if ((stateConfig === null || stateConfig === void 0 ? void 0 : stateConfig.effects) !== false) {
|
|
74
|
+
plugins.push(effects());
|
|
75
|
+
}
|
|
76
|
+
if ((stateConfig === null || stateConfig === void 0 ? void 0 : stateConfig.autoActions) !== false) {
|
|
77
|
+
plugins.push(autoActions());
|
|
78
|
+
}
|
|
79
|
+
if ((stateConfig === null || stateConfig === void 0 ? void 0 : stateConfig.immer) !== false) {
|
|
80
|
+
plugins.push(immer());
|
|
81
|
+
}
|
|
82
|
+
return ((props === null || props === void 0 ? void 0 : props.plugins) || []).concat(plugins);
|
|
83
|
+
};
|
|
84
|
+
var config = _objectSpreadProps(_objectSpread({}, props || {}), {
|
|
85
|
+
plugins: createStatePlugins()
|
|
86
|
+
});
|
|
87
|
+
return originCreateStore(config);
|
|
88
|
+
};
|
|
89
|
+
export { autoActions, createStore, effects, immer };
|
|
@@ -1,21 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
function _arrayLikeToArray(arr, len) {
|
|
2
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
3
|
+
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
|
4
|
+
return arr2;
|
|
5
|
+
}
|
|
6
|
+
function _arrayWithHoles(arr) {
|
|
7
|
+
if (Array.isArray(arr)) return arr;
|
|
8
|
+
}
|
|
9
|
+
function _arrayWithoutHoles(arr) {
|
|
10
|
+
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
11
|
+
}
|
|
12
|
+
function _iterableToArray(iter) {
|
|
13
|
+
if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
|
|
14
|
+
}
|
|
15
|
+
function _nonIterableRest() {
|
|
16
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
17
|
+
}
|
|
18
|
+
function _nonIterableSpread() {
|
|
19
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
20
|
+
}
|
|
21
|
+
function _toArray(arr) {
|
|
22
|
+
return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest();
|
|
23
|
+
}
|
|
24
|
+
function _toConsumableArray(arr) {
|
|
25
|
+
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
26
|
+
}
|
|
27
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
28
|
+
if (!o) return;
|
|
29
|
+
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
30
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
31
|
+
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
32
|
+
if (n === "Map" || n === "Set") return Array.from(n);
|
|
33
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
34
|
+
}
|
|
35
|
+
import supertest from "supertest";
|
|
5
36
|
import { getApp } from "../cli/bff/app";
|
|
6
37
|
function request() {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
export { request };
|
|
38
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
39
|
+
args[_key] = arguments[_key];
|
|
40
|
+
}
|
|
41
|
+
var _args = _toArray(args), fn = _args[0], extraArgs = _args.slice(1);
|
|
42
|
+
var app = getApp();
|
|
43
|
+
if (!fn) {
|
|
44
|
+
return supertest(app);
|
|
45
|
+
}
|
|
46
|
+
fn.returnHttp = true;
|
|
47
|
+
var res = fn.apply(void 0, _toConsumableArray(extraArgs));
|
|
48
|
+
fn.returnHttp = false;
|
|
49
|
+
return res;
|
|
50
|
+
}
|
|
51
|
+
export { request };
|
|
@@ -1,15 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
+
});
|
|
12
26
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
27
|
+
return target;
|
|
28
|
+
}
|
|
29
|
+
var allowedFeatures = [
|
|
30
|
+
"router",
|
|
31
|
+
"state"
|
|
32
|
+
];
|
|
33
|
+
function resolvePlugins(features) {
|
|
34
|
+
var plugins = [];
|
|
35
|
+
if (!features) {
|
|
36
|
+
return plugins;
|
|
37
|
+
}
|
|
38
|
+
Object.keys(features).forEach(function(feature) {
|
|
39
|
+
if (allowedFeatures.includes(feature)) {
|
|
40
|
+
var curPluginRes = require("@modern-js/runtime/plugins")[feature](_objectSpread({}, features[feature]));
|
|
41
|
+
plugins.push(curPluginRes);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
return plugins;
|
|
45
|
+
}
|
|
46
|
+
export { resolvePlugins as default };
|
|
@@ -5,6 +5,7 @@ import { TestConfigOperator } from './testConfigOperator';
|
|
|
5
5
|
/**
|
|
6
6
|
* Parse jest config
|
|
7
7
|
*/
|
|
8
|
+
|
|
8
9
|
declare const getJestUtils: (testConfig: TestConfig) => TestConfigOperator;
|
|
9
10
|
declare const patchConfig: (testOperator: TestConfigOperator) => Promise<Partial<{
|
|
10
11
|
automock: boolean;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { JestConfig, TestConfig } from '../types';
|
|
2
|
+
|
|
2
3
|
declare class TestConfigOperator {
|
|
3
4
|
private _testConfig;
|
|
4
5
|
private _jestConfig;
|
|
@@ -129,4 +130,5 @@ declare class TestConfigOperator {
|
|
|
129
130
|
watchPlugins: (string | [string, Record<string, unknown>])[];
|
|
130
131
|
}>;
|
|
131
132
|
}
|
|
133
|
+
|
|
132
134
|
export { TestConfigOperator };
|
|
@@ -14,10 +14,12 @@ declare type Argv = Omit<Config.Argv, '_' | '$0'>;
|
|
|
14
14
|
/**
|
|
15
15
|
* Node API: execute jest
|
|
16
16
|
*/
|
|
17
|
+
|
|
17
18
|
export declare function runJest(config: Argv, pwd?: string): Promise<void>;
|
|
18
19
|
/**
|
|
19
20
|
* Node API: run test
|
|
20
21
|
*/
|
|
22
|
+
|
|
21
23
|
export declare function runTest(api: PluginAPI<{
|
|
22
24
|
hooks: Hooks;
|
|
23
25
|
userConfig: UserConfig;
|
|
@@ -6,6 +6,7 @@ interface TSConfig {
|
|
|
6
6
|
/**
|
|
7
7
|
* Read `compilerOptions` in the current pwd's tsconfig.json file
|
|
8
8
|
*/
|
|
9
|
+
|
|
9
10
|
export declare const readCompilerOptions: (pwd?: string, filename?: string) => TSConfig['compilerOptions'];
|
|
10
11
|
export declare const getModuleNameMapper: (alias: any) => any;
|
|
11
12
|
export {};
|
|
@@ -16,9 +16,11 @@ export declare const setJestConfigForBFF: ({
|
|
|
16
16
|
routes: any[];
|
|
17
17
|
utils: TestConfigOperator;
|
|
18
18
|
}) => Promise<void>;
|
|
19
|
+
|
|
19
20
|
declare const _default: () => CliPlugin<{
|
|
20
21
|
hooks: Hooks;
|
|
21
22
|
userConfig: UserConfig;
|
|
22
23
|
normalizedConfig: Required<UserConfig>;
|
|
23
24
|
}>;
|
|
25
|
+
|
|
24
26
|
export default _default;
|
|
@@ -3,9 +3,11 @@ import { TestConfigOperator } from '../base';
|
|
|
3
3
|
import type { Hooks } from '../base/hook';
|
|
4
4
|
import type { UserConfig } from '../base/config';
|
|
5
5
|
export declare const mergeUserJestConfig: (testUtils: TestConfigOperator) => void;
|
|
6
|
+
|
|
6
7
|
declare const _default: () => CliPlugin<{
|
|
7
8
|
hooks: Hooks;
|
|
8
9
|
userConfig: UserConfig;
|
|
9
10
|
normalizedConfig: Required<UserConfig>;
|
|
10
11
|
}>;
|
|
12
|
+
|
|
11
13
|
export default _default;
|
|
@@ -4,6 +4,7 @@ interface CreateAppProps {
|
|
|
4
4
|
entry?: string;
|
|
5
5
|
children?: React.ReactElement;
|
|
6
6
|
}
|
|
7
|
+
|
|
7
8
|
declare class ModernRuntime {
|
|
8
9
|
private options;
|
|
9
10
|
constructor(options: UserConfig<{
|
|
@@ -20,5 +21,7 @@ declare class ModernRuntime {
|
|
|
20
21
|
}>): void;
|
|
21
22
|
createApp(props?: CreateAppProps): React.ComponentType<any>;
|
|
22
23
|
}
|
|
24
|
+
|
|
23
25
|
declare const _default: ModernRuntime;
|
|
26
|
+
|
|
24
27
|
export default _default;
|
package/package.json
CHANGED
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "2.0.0-beta.
|
|
15
|
-
"jsnext:source": "./src/index.ts",
|
|
16
|
-
"types": "./dist/types/index.d.ts",
|
|
17
|
-
"main": "./dist/js/node/index.js",
|
|
18
|
-
"module": "./dist/js/treeshaking/index.js",
|
|
19
|
-
"jsnext:modern": "./dist/js/modern/index.js",
|
|
14
|
+
"version": "2.0.0-beta.6",
|
|
15
|
+
"jsnext:source": "./src/cli/index.ts",
|
|
16
|
+
"types": "./dist/types/cli/index.d.ts",
|
|
17
|
+
"main": "./dist/js/node/cli/index.js",
|
|
18
|
+
"module": "./dist/js/treeshaking/cli/index.js",
|
|
19
|
+
"jsnext:modern": "./dist/js/modern/cli/index.js",
|
|
20
20
|
"exports": {
|
|
21
21
|
"./types": {
|
|
22
22
|
"jsnext:source": "./types/index.d.ts",
|
|
@@ -27,12 +27,8 @@
|
|
|
27
27
|
"default": "./types/index.d.ts"
|
|
28
28
|
},
|
|
29
29
|
".": {
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
"import": "./dist/js/modern/runtime-testing/index.js",
|
|
33
|
-
"require": "./dist/js/node/runtime-testing/index.js"
|
|
34
|
-
},
|
|
35
|
-
"default": "./dist/js/treeshaking/runtime-testing/index.js"
|
|
30
|
+
"jsnext:source": "./src/cli/index.ts",
|
|
31
|
+
"default": "./dist/js/node/cli/index.js"
|
|
36
32
|
},
|
|
37
33
|
"./runtime": {
|
|
38
34
|
"jsnext:source": "./src/runtime-testing/index.ts",
|
|
@@ -66,7 +62,7 @@
|
|
|
66
62
|
"typesVersions": {
|
|
67
63
|
"*": {
|
|
68
64
|
".": [
|
|
69
|
-
"./dist/types/
|
|
65
|
+
"./dist/types/cli/index.d.ts"
|
|
70
66
|
],
|
|
71
67
|
"cli": [
|
|
72
68
|
"./dist/types/cli/index.d.ts"
|
|
@@ -111,16 +107,16 @@
|
|
|
111
107
|
"jest": "^27.0.6",
|
|
112
108
|
"ts-jest": "^27.0.4",
|
|
113
109
|
"yargs": "^17.0.1",
|
|
114
|
-
"@modern-js/babel-compiler": "2.0.0-beta.
|
|
115
|
-
"@modern-js/utils": "2.0.0-beta.
|
|
116
|
-
"@modern-js/babel-preset-app": "2.0.0-beta.
|
|
117
|
-
"@modern-js/plugin": "2.0.0-beta.
|
|
118
|
-
"@modern-js/prod-server": "2.0.0-beta.
|
|
110
|
+
"@modern-js/babel-compiler": "2.0.0-beta.6",
|
|
111
|
+
"@modern-js/utils": "2.0.0-beta.6",
|
|
112
|
+
"@modern-js/babel-preset-app": "2.0.0-beta.6",
|
|
113
|
+
"@modern-js/plugin": "2.0.0-beta.6",
|
|
114
|
+
"@modern-js/prod-server": "2.0.0-beta.6"
|
|
119
115
|
},
|
|
120
116
|
"peerDependencies": {
|
|
121
117
|
"react": ">=17",
|
|
122
118
|
"react-dom": ">=17",
|
|
123
|
-
"@modern-js/runtime": "^2.0.0-beta.
|
|
119
|
+
"@modern-js/runtime": "^2.0.0-beta.6"
|
|
124
120
|
},
|
|
125
121
|
"peerDependenciesMeta": {
|
|
126
122
|
"@modern-js/runtime": {
|
|
@@ -137,12 +133,12 @@
|
|
|
137
133
|
"@jest/types": "^27.0.6",
|
|
138
134
|
"jest": "^27",
|
|
139
135
|
"typescript": "^4",
|
|
140
|
-
"@modern-js/core": "2.0.0-beta.
|
|
141
|
-
"@modern-js/types": "2.0.0-beta.
|
|
142
|
-
"@modern-js/runtime": "2.0.0-beta.
|
|
143
|
-
"@
|
|
144
|
-
"@
|
|
145
|
-
"@scripts/
|
|
136
|
+
"@modern-js/core": "2.0.0-beta.6",
|
|
137
|
+
"@modern-js/types": "2.0.0-beta.6",
|
|
138
|
+
"@modern-js/runtime": "2.0.0-beta.6",
|
|
139
|
+
"@scripts/jest-config": "2.0.0-beta.6",
|
|
140
|
+
"@modern-js/bff-core": "2.0.0-beta.6",
|
|
141
|
+
"@scripts/build": "2.0.0-beta.6"
|
|
146
142
|
},
|
|
147
143
|
"sideEffects": false,
|
|
148
144
|
"modernConfig": {},
|