@modern-js/plugin-testing 2.21.0 → 2.21.2-alpha.0
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 +13 -0
- package/dist/cjs/base/config/index.js +9 -3
- package/dist/cjs/base/config/patches/assetsModule.js +3 -1
- package/dist/cjs/base/config/patches/filemock.js +3 -1
- package/dist/cjs/base/config/patches/index.js +3 -1
- package/dist/cjs/base/config/patches/transformer.js +3 -1
- package/dist/cjs/base/config/testConfigOperator.js +3 -1
- package/dist/cjs/base/config/transformer/babelTransformer.js +3 -1
- package/dist/cjs/base/hook.js +9 -3
- package/dist/cjs/base/index.js +18 -6
- package/dist/cjs/base/runJest.js +6 -2
- package/dist/cjs/base/utils.js +9 -3
- package/dist/cjs/cli/bff/app.js +12 -4
- package/dist/cjs/cli/bff/constant.js +3 -1
- package/dist/cjs/cli/bff/index.js +6 -2
- package/dist/cjs/cli/bff/mockAPI.js +3 -1
- package/dist/cjs/cli/bff/setup.js +14 -14
- package/dist/cjs/cli/bff/utils/index.js +3 -1
- package/dist/cjs/cli/index.js +7 -2
- package/dist/cjs/cli/test.js +3 -1
- package/dist/cjs/constant.js +3 -1
- package/dist/cjs/runtime-testing/app.js +3 -1
- package/dist/cjs/runtime-testing/base.js +5 -11
- package/dist/cjs/runtime-testing/{request.js → bff.js} +4 -2
- package/dist/cjs/runtime-testing/customRender.js +3 -1
- package/dist/cjs/runtime-testing/reduck.js +12 -4
- package/dist/cjs/runtime-testing/resolvePlugins.js +3 -1
- package/dist/esm/cli/bff/setup.js +15 -14
- package/dist/esm/cli/index.js +1 -0
- package/dist/esm/runtime-testing/base.js +0 -1
- package/dist/esm/runtime-testing/{request.js → bff.js} +1 -1
- package/dist/esm-node/cli/bff/setup.js +14 -14
- package/dist/esm-node/cli/index.js +1 -0
- package/dist/esm-node/runtime-testing/base.js +0 -1
- package/dist/esm-node/runtime-testing/bff.js +14 -0
- package/dist/js/modern/base/config/index.js +36 -0
- package/dist/js/modern/base/config/patches/assetsModule.js +11 -0
- package/dist/js/modern/base/config/patches/filemock.js +4 -0
- package/dist/js/modern/base/config/patches/index.js +34 -0
- package/dist/js/modern/base/config/patches/transformer.js +38 -0
- package/dist/js/modern/base/config/resolver.js +21 -0
- package/dist/js/modern/base/config/testConfigOperator.js +69 -0
- package/dist/js/modern/base/config/transformer/babelTransformer.js +19 -0
- package/dist/js/modern/base/hook.js +12 -0
- package/dist/js/modern/base/index.js +14 -0
- package/dist/js/modern/base/runJest.js +102 -0
- package/dist/js/modern/base/types/index.js +0 -0
- package/dist/js/modern/base/utils.js +66 -0
- package/dist/js/modern/cli/bff/app.js +58 -0
- package/dist/js/modern/cli/bff/constant.js +4 -0
- package/dist/js/modern/cli/bff/index.js +149 -0
- package/dist/js/modern/cli/bff/mockAPI.js +109 -0
- package/dist/js/modern/cli/bff/setup.js +75 -0
- package/dist/js/modern/cli/bff/utils/index.js +37 -0
- package/dist/js/modern/cli/index.js +115 -0
- package/dist/js/modern/cli/test.js +61 -0
- package/dist/js/modern/constant.js +4 -0
- package/dist/js/modern/index.js +3 -0
- package/dist/js/modern/runtime-testing/app.js +48 -0
- package/dist/js/modern/runtime-testing/base.js +7 -0
- package/dist/js/modern/runtime-testing/customRender.js +25 -0
- package/dist/js/modern/runtime-testing/index.js +2 -0
- package/dist/js/modern/runtime-testing/reduck.js +55 -0
- package/dist/{esm-node → js/modern}/runtime-testing/request.js +3 -1
- package/dist/js/modern/runtime-testing/resolvePlugins.js +33 -0
- package/dist/js/node/base/config/index.js +67 -0
- package/dist/js/node/base/config/patches/assetsModule.js +40 -0
- package/dist/js/node/base/config/patches/filemock.js +25 -0
- package/dist/js/node/base/config/patches/index.js +57 -0
- package/dist/js/node/base/config/patches/transformer.js +67 -0
- package/dist/js/node/base/config/resolver.js +30 -0
- package/dist/js/node/base/config/testConfigOperator.js +90 -0
- package/dist/js/node/base/config/transformer/babelTransformer.js +46 -0
- package/dist/js/node/base/hook.js +37 -0
- package/dist/js/node/base/index.js +43 -0
- package/dist/js/node/base/runJest.js +132 -0
- package/dist/js/node/base/types/index.js +15 -0
- package/dist/js/node/base/utils.js +95 -0
- package/dist/js/node/cli/bff/app.js +84 -0
- package/dist/js/node/cli/bff/constant.js +27 -0
- package/dist/js/node/cli/bff/index.js +173 -0
- package/dist/js/node/cli/bff/mockAPI.js +134 -0
- package/dist/js/node/cli/bff/setup.js +84 -0
- package/dist/js/node/cli/bff/utils/index.js +64 -0
- package/dist/js/node/cli/index.js +135 -0
- package/dist/js/node/cli/test.js +88 -0
- package/dist/js/node/constant.js +27 -0
- package/dist/js/node/index.js +19 -0
- package/dist/js/node/runtime-testing/app.js +73 -0
- package/dist/js/node/runtime-testing/base.js +38 -0
- package/dist/js/node/runtime-testing/customRender.js +50 -0
- package/dist/js/node/runtime-testing/index.js +18 -0
- package/dist/js/node/runtime-testing/reduck.js +85 -0
- package/dist/js/node/runtime-testing/request.js +45 -0
- package/dist/js/node/runtime-testing/resolvePlugins.js +52 -0
- package/dist/js/treeshaking/base/config/index.js +154 -0
- package/dist/js/treeshaking/base/config/patches/assetsModule.js +9 -0
- package/dist/js/treeshaking/base/config/patches/filemock.js +2 -0
- package/dist/js/treeshaking/base/config/patches/index.js +225 -0
- package/dist/js/treeshaking/base/config/patches/transformer.js +36 -0
- package/dist/js/treeshaking/base/config/resolver.js +37 -0
- package/dist/js/treeshaking/base/config/testConfigOperator.js +127 -0
- package/dist/js/treeshaking/base/config/transformer/babelTransformer.js +17 -0
- package/dist/js/treeshaking/base/hook.js +8 -0
- package/dist/js/treeshaking/base/index.js +7 -0
- package/dist/js/treeshaking/base/runJest.js +292 -0
- package/dist/js/treeshaking/base/types/index.js +1 -0
- package/dist/js/treeshaking/base/utils.js +76 -0
- package/dist/js/treeshaking/cli/bff/app.js +200 -0
- package/dist/js/treeshaking/cli/bff/constant.js +2 -0
- package/dist/js/treeshaking/cli/bff/index.js +297 -0
- package/dist/js/treeshaking/cli/bff/mockAPI.js +188 -0
- package/dist/js/treeshaking/cli/bff/setup.js +192 -0
- package/dist/js/treeshaking/cli/bff/utils/index.js +47 -0
- package/dist/js/treeshaking/cli/index.js +255 -0
- package/dist/js/treeshaking/cli/test.js +180 -0
- package/dist/js/treeshaking/constant.js +2 -0
- package/dist/js/treeshaking/index.js +3 -0
- package/dist/js/treeshaking/runtime-testing/app.js +90 -0
- package/dist/js/treeshaking/runtime-testing/base.js +4 -0
- package/dist/js/treeshaking/runtime-testing/customRender.js +41 -0
- package/dist/js/treeshaking/runtime-testing/index.js +2 -0
- package/dist/js/treeshaking/runtime-testing/reduck.js +89 -0
- package/dist/js/treeshaking/runtime-testing/request.js +51 -0
- package/dist/js/treeshaking/runtime-testing/resolvePlugins.js +46 -0
- package/dist/types/runtime-testing/base.d.ts +1 -2
- package/dist/types/runtime-testing/{request.d.ts → bff.d.ts} +1 -1
- package/package.json +23 -14
- package/types/index.d.ts +6 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @modern-js/plugin-testing
|
|
2
2
|
|
|
3
|
+
## 2.21.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [78e3ac8]
|
|
8
|
+
- Updated dependencies [2728724]
|
|
9
|
+
- @modern-js/prod-server@2.21.1
|
|
10
|
+
- @modern-js/runtime@2.21.1
|
|
11
|
+
- @modern-js/babel-preset-app@2.21.1
|
|
12
|
+
- @modern-js/babel-compiler@2.21.1
|
|
13
|
+
- @modern-js/plugin@2.21.1
|
|
14
|
+
- @modern-js/utils@2.21.1
|
|
15
|
+
|
|
3
16
|
## 2.21.0
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
|
@@ -10,9 +10,15 @@ function _export(target, all) {
|
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
_export(exports, {
|
|
13
|
-
DEFAULT_RESOLVER_PATH: ()
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
DEFAULT_RESOLVER_PATH: function() {
|
|
14
|
+
return DEFAULT_RESOLVER_PATH;
|
|
15
|
+
},
|
|
16
|
+
getJestUtils: function() {
|
|
17
|
+
return getJestUtils;
|
|
18
|
+
},
|
|
19
|
+
patchConfig: function() {
|
|
20
|
+
return patchConfig;
|
|
21
|
+
}
|
|
16
22
|
});
|
|
17
23
|
const _patches = require("./patches");
|
|
18
24
|
const _testConfigOperator = require("./testConfigOperator");
|
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "patchAssetsModule", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return patchAssetsModule;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const patchAssetsModule = (testOperator) => {
|
|
10
12
|
testOperator.mergeJestConfig({
|
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "applyPatches", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return applyPatches;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _transformer = require("./transformer");
|
|
10
12
|
const _assetsModule = require("./assetsModule");
|
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "patchTransformer", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return patchTransformer;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _utils = require("../../utils");
|
|
10
12
|
const resolveTsCompilerOptions = () => {
|
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "TestConfigOperator", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return TestConfigOperator;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _define_property = require("@swc/helpers/_/_define_property");
|
|
10
12
|
const _lodash = require("@modern-js/utils/lodash");
|
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "default", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return _default;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
10
12
|
const _babeljest = /* @__PURE__ */ _interop_require_default._(require("babel-jest"));
|
package/dist/cjs/base/hook.js
CHANGED
|
@@ -10,9 +10,15 @@ function _export(target, all) {
|
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
_export(exports, {
|
|
13
|
-
jestConfigHook: ()
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
jestConfigHook: function() {
|
|
14
|
+
return jestConfigHook;
|
|
15
|
+
},
|
|
16
|
+
afterTestHook: function() {
|
|
17
|
+
return afterTestHook;
|
|
18
|
+
},
|
|
19
|
+
testingHooks: function() {
|
|
20
|
+
return testingHooks;
|
|
21
|
+
}
|
|
16
22
|
});
|
|
17
23
|
const _plugin = require("@modern-js/plugin");
|
|
18
24
|
const jestConfigHook = (0, _plugin.createAsyncPipeline)();
|
package/dist/cjs/base/index.js
CHANGED
|
@@ -10,12 +10,24 @@ function _export(target, all) {
|
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
_export(exports, {
|
|
13
|
-
runTest: ()
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
runTest: function() {
|
|
14
|
+
return _runJest.runTest;
|
|
15
|
+
},
|
|
16
|
+
runJest: function() {
|
|
17
|
+
return _runJest.runJest;
|
|
18
|
+
},
|
|
19
|
+
getModuleNameMapper: function() {
|
|
20
|
+
return _utils.getModuleNameMapper;
|
|
21
|
+
},
|
|
22
|
+
DEFAULT_RESOLVER_PATH: function() {
|
|
23
|
+
return _config.DEFAULT_RESOLVER_PATH;
|
|
24
|
+
},
|
|
25
|
+
TestConfigOperator: function() {
|
|
26
|
+
return _testConfigOperator.TestConfigOperator;
|
|
27
|
+
},
|
|
28
|
+
testingHooks: function() {
|
|
29
|
+
return _hook.testingHooks;
|
|
30
|
+
}
|
|
19
31
|
});
|
|
20
32
|
const _export_star = require("@swc/helpers/_/_export_star");
|
|
21
33
|
const _runJest = require("./runJest");
|
package/dist/cjs/base/runJest.js
CHANGED
|
@@ -10,8 +10,12 @@ function _export(target, all) {
|
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
_export(exports, {
|
|
13
|
-
runJest: ()
|
|
14
|
-
|
|
13
|
+
runJest: function() {
|
|
14
|
+
return runJest;
|
|
15
|
+
},
|
|
16
|
+
runTest: function() {
|
|
17
|
+
return runTest;
|
|
18
|
+
}
|
|
15
19
|
});
|
|
16
20
|
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
17
21
|
const _yargs = /* @__PURE__ */ _interop_require_default._(require("yargs/yargs"));
|
package/dist/cjs/base/utils.js
CHANGED
|
@@ -10,9 +10,15 @@ function _export(target, all) {
|
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
_export(exports, {
|
|
13
|
-
debug: ()
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
debug: function() {
|
|
14
|
+
return debug;
|
|
15
|
+
},
|
|
16
|
+
readCompilerOptions: function() {
|
|
17
|
+
return readCompilerOptions;
|
|
18
|
+
},
|
|
19
|
+
getModuleNameMapper: function() {
|
|
20
|
+
return getModuleNameMapper;
|
|
21
|
+
}
|
|
16
22
|
});
|
|
17
23
|
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
18
24
|
const _fs = /* @__PURE__ */ _interop_require_default._(require("fs"));
|
package/dist/cjs/cli/bff/app.js
CHANGED
|
@@ -10,10 +10,18 @@ function _export(target, all) {
|
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
_export(exports, {
|
|
13
|
-
isInHandler: ()
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
isInHandler: function() {
|
|
14
|
+
return isInHandler;
|
|
15
|
+
},
|
|
16
|
+
createApp: function() {
|
|
17
|
+
return createApp;
|
|
18
|
+
},
|
|
19
|
+
getApp: function() {
|
|
20
|
+
return getApp;
|
|
21
|
+
},
|
|
22
|
+
closeServer: function() {
|
|
23
|
+
return closeServer;
|
|
24
|
+
}
|
|
17
25
|
});
|
|
18
26
|
const _async_hooks = require("async_hooks");
|
|
19
27
|
const _prodserver = require("@modern-js/prod-server");
|
|
@@ -10,8 +10,12 @@ function _export(target, all) {
|
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
_export(exports, {
|
|
13
|
-
setJestConfigForBFF: ()
|
|
14
|
-
|
|
13
|
+
setJestConfigForBFF: function() {
|
|
14
|
+
return setJestConfigForBFF;
|
|
15
|
+
},
|
|
16
|
+
default: function() {
|
|
17
|
+
return _default;
|
|
18
|
+
}
|
|
15
19
|
});
|
|
16
20
|
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
17
21
|
const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
|
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "default", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return _default;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
10
12
|
const _pathtoregexp = /* @__PURE__ */ _interop_require_wildcard._(require("path-to-regexp"));
|
|
@@ -18,21 +18,22 @@ const setup = () => {
|
|
|
18
18
|
const bff_info = global[_constant.bff_info_key];
|
|
19
19
|
const prefix = bff_info === null || bff_info === void 0 ? void 0 : (_bff_info_modernUserConfig = bff_info.modernUserConfig) === null || _bff_info_modernUserConfig === void 0 ? void 0 : (_bff_info_modernUserConfig_bff = _bff_info_modernUserConfig.bff) === null || _bff_info_modernUserConfig_bff === void 0 ? void 0 : _bff_info_modernUserConfig_bff.prefix;
|
|
20
20
|
const httpMethodDecider = bff_info === null || bff_info === void 0 ? void 0 : (_bff_info_modernUserConfig1 = bff_info.modernUserConfig) === null || _bff_info_modernUserConfig1 === void 0 ? void 0 : (_bff_info_modernUserConfig_bff1 = _bff_info_modernUserConfig1.bff) === null || _bff_info_modernUserConfig_bff1 === void 0 ? void 0 : _bff_info_modernUserConfig_bff1.httpMethodDecider;
|
|
21
|
-
const apiRouter = new _bffcore.ApiRouter({
|
|
22
|
-
apiDir: _path.default.join(bff_info.appDir, "./api"),
|
|
23
|
-
prefix,
|
|
24
|
-
httpMethodDecider
|
|
25
|
-
});
|
|
26
|
-
const apiInfos = apiRouter.getApiHandlers();
|
|
27
|
-
const apiInfosByFile = apiInfos.reduce((res, apiInfo) => {
|
|
28
|
-
if (!res[apiInfo.filename]) {
|
|
29
|
-
res[apiInfo.filename] = [];
|
|
30
|
-
}
|
|
31
|
-
res[apiInfo.filename].push(apiInfo);
|
|
32
|
-
return res;
|
|
33
|
-
}, {});
|
|
34
21
|
let app = null;
|
|
35
22
|
beforeAll(async () => {
|
|
23
|
+
const apiRouter = new _bffcore.ApiRouter({
|
|
24
|
+
apiDir: _path.default.join(bff_info.appDir, "./api"),
|
|
25
|
+
prefix,
|
|
26
|
+
httpMethodDecider
|
|
27
|
+
});
|
|
28
|
+
const apiInfos = apiRouter.getApiHandlers();
|
|
29
|
+
const apiInfosByFile = apiInfos.reduce((res, apiInfo) => {
|
|
30
|
+
if (!res[apiInfo.filename]) {
|
|
31
|
+
res[apiInfo.filename] = [];
|
|
32
|
+
}
|
|
33
|
+
res[apiInfo.filename].push(apiInfo);
|
|
34
|
+
return res;
|
|
35
|
+
}, {});
|
|
36
|
+
(0, _mockAPI.default)(apiInfosByFile);
|
|
36
37
|
if (!app) {
|
|
37
38
|
app = await (0, _app.createApp)(bff_info.appDir, bff_info.modernUserConfig, bff_info.plugins, bff_info.routes);
|
|
38
39
|
}
|
|
@@ -40,6 +41,5 @@ const setup = () => {
|
|
|
40
41
|
afterAll(async () => {
|
|
41
42
|
await (0, _app.closeServer)();
|
|
42
43
|
});
|
|
43
|
-
(0, _mockAPI.default)(apiInfosByFile);
|
|
44
44
|
};
|
|
45
45
|
setup();
|
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "isBFFProject", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return isBFFProject;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
10
12
|
const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
|
package/dist/cjs/cli/index.js
CHANGED
|
@@ -10,8 +10,12 @@ function _export(target, all) {
|
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
_export(exports, {
|
|
13
|
-
mergeUserJestConfig: ()
|
|
14
|
-
|
|
13
|
+
mergeUserJestConfig: function() {
|
|
14
|
+
return mergeUserJestConfig;
|
|
15
|
+
},
|
|
16
|
+
default: function() {
|
|
17
|
+
return _default;
|
|
18
|
+
}
|
|
15
19
|
});
|
|
16
20
|
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
17
21
|
const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
|
|
@@ -57,6 +61,7 @@ const _default = () => {
|
|
|
57
61
|
// The module-tools alias configuration is different and more specific than app-tools.
|
|
58
62
|
// So for the time being, the @ alias is configured here.
|
|
59
63
|
"@": _path.default.join(appContext.appDirectory, "src"),
|
|
64
|
+
"@modern-js/runtime/testing/bff": require.resolve("@modern-js/plugin-testing/bff"),
|
|
60
65
|
"@modern-js/runtime/testing": testingExportsUtils.getPath()
|
|
61
66
|
}
|
|
62
67
|
}
|
package/dist/cjs/cli/test.js
CHANGED
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "default", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return _default;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
10
12
|
const _path = /* @__PURE__ */ _interop_require_default._(require("path"));
|
package/dist/cjs/constant.js
CHANGED
|
@@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "MODERNJS_CONFIG_KEY", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return MODERNJS_CONFIG_KEY;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const MODERNJS_CONFIG_KEY = "__modernjs_config__";
|
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "default", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return _default;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _define_property = require("@swc/helpers/_/_define_property");
|
|
10
12
|
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
@@ -2,19 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
_export(exports, {
|
|
13
|
-
renderApp: () => _customRender.default,
|
|
14
|
-
testBff: () => _request.request
|
|
5
|
+
Object.defineProperty(exports, "renderApp", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return _customRender.default;
|
|
9
|
+
}
|
|
15
10
|
});
|
|
16
11
|
const _export_star = require("@swc/helpers/_/_export_star");
|
|
17
12
|
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
18
13
|
const _customRender = /* @__PURE__ */ _interop_require_default._(require("./customRender"));
|
|
19
14
|
_export_star._(require("@testing-library/react"), exports);
|
|
20
|
-
const _request = require("./request");
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
Object.defineProperty(exports, "
|
|
5
|
+
Object.defineProperty(exports, "testBff", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return request;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
10
12
|
const _supertest = /* @__PURE__ */ _interop_require_default._(require("supertest"));
|
|
@@ -4,7 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
});
|
|
5
5
|
Object.defineProperty(exports, "default", {
|
|
6
6
|
enumerable: true,
|
|
7
|
-
get: ()
|
|
7
|
+
get: function() {
|
|
8
|
+
return _default;
|
|
9
|
+
}
|
|
8
10
|
});
|
|
9
11
|
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
10
12
|
const _react = /* @__PURE__ */ _interop_require_default._(require("react"));
|
|
@@ -10,10 +10,18 @@ function _export(target, all) {
|
|
|
10
10
|
});
|
|
11
11
|
}
|
|
12
12
|
_export(exports, {
|
|
13
|
-
effects: ()
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
effects: function() {
|
|
14
|
+
return effects;
|
|
15
|
+
},
|
|
16
|
+
immer: function() {
|
|
17
|
+
return immer;
|
|
18
|
+
},
|
|
19
|
+
autoActions: function() {
|
|
20
|
+
return autoActions;
|
|
21
|
+
},
|
|
22
|
+
createStore: function() {
|
|
23
|
+
return createStore;
|
|
24
|
+
}
|
|
17
25
|
});
|
|
18
26
|
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
|
19
27
|
const _store = require("@modern-js-reduck/store");
|
|
@@ -15,24 +15,26 @@ var setup = function() {
|
|
|
15
15
|
var bff_info = global[bff_info_key];
|
|
16
16
|
var prefix = bff_info === null || bff_info === void 0 ? void 0 : (_bff_info_modernUserConfig = bff_info.modernUserConfig) === null || _bff_info_modernUserConfig === void 0 ? void 0 : (_bff_info_modernUserConfig_bff = _bff_info_modernUserConfig.bff) === null || _bff_info_modernUserConfig_bff === void 0 ? void 0 : _bff_info_modernUserConfig_bff.prefix;
|
|
17
17
|
var httpMethodDecider = bff_info === null || bff_info === void 0 ? void 0 : (_bff_info_modernUserConfig1 = bff_info.modernUserConfig) === null || _bff_info_modernUserConfig1 === void 0 ? void 0 : (_bff_info_modernUserConfig_bff1 = _bff_info_modernUserConfig1.bff) === null || _bff_info_modernUserConfig_bff1 === void 0 ? void 0 : _bff_info_modernUserConfig_bff1.httpMethodDecider;
|
|
18
|
-
var apiRouter = new ApiRouter({
|
|
19
|
-
apiDir: path.join(bff_info.appDir, "./api"),
|
|
20
|
-
prefix: prefix,
|
|
21
|
-
httpMethodDecider: httpMethodDecider
|
|
22
|
-
});
|
|
23
|
-
var apiInfos = apiRouter.getApiHandlers();
|
|
24
|
-
var apiInfosByFile = apiInfos.reduce(function(res, apiInfo) {
|
|
25
|
-
if (!res[apiInfo.filename]) {
|
|
26
|
-
res[apiInfo.filename] = [];
|
|
27
|
-
}
|
|
28
|
-
res[apiInfo.filename].push(apiInfo);
|
|
29
|
-
return res;
|
|
30
|
-
}, {});
|
|
31
18
|
var app = null;
|
|
32
19
|
beforeAll(/* @__PURE__ */ _async_to_generator(function() {
|
|
20
|
+
var apiRouter, apiInfos, apiInfosByFile;
|
|
33
21
|
return _ts_generator(this, function(_state) {
|
|
34
22
|
switch (_state.label) {
|
|
35
23
|
case 0:
|
|
24
|
+
apiRouter = new ApiRouter({
|
|
25
|
+
apiDir: path.join(bff_info.appDir, "./api"),
|
|
26
|
+
prefix: prefix,
|
|
27
|
+
httpMethodDecider: httpMethodDecider
|
|
28
|
+
});
|
|
29
|
+
apiInfos = apiRouter.getApiHandlers();
|
|
30
|
+
apiInfosByFile = apiInfos.reduce(function(res, apiInfo) {
|
|
31
|
+
if (!res[apiInfo.filename]) {
|
|
32
|
+
res[apiInfo.filename] = [];
|
|
33
|
+
}
|
|
34
|
+
res[apiInfo.filename].push(apiInfo);
|
|
35
|
+
return res;
|
|
36
|
+
}, {});
|
|
37
|
+
mockAPI(apiInfosByFile);
|
|
36
38
|
if (!!app)
|
|
37
39
|
return [
|
|
38
40
|
3,
|
|
@@ -68,6 +70,5 @@ var setup = function() {
|
|
|
68
70
|
}
|
|
69
71
|
});
|
|
70
72
|
}));
|
|
71
|
-
mockAPI(apiInfosByFile);
|
|
72
73
|
};
|
|
73
74
|
setup();
|
package/dist/esm/cli/index.js
CHANGED
|
@@ -58,6 +58,7 @@ export default function() {
|
|
|
58
58
|
// The module-tools alias configuration is different and more specific than app-tools.
|
|
59
59
|
// So for the time being, the @ alias is configured here.
|
|
60
60
|
"@": path.join(appContext.appDirectory, "src"),
|
|
61
|
+
"@modern-js/runtime/testing/bff": require.resolve("@modern-js/plugin-testing/bff"),
|
|
61
62
|
"@modern-js/runtime/testing": testingExportsUtils.getPath()
|
|
62
63
|
}
|
|
63
64
|
}
|
|
@@ -13,21 +13,22 @@ const setup = () => {
|
|
|
13
13
|
const bff_info = global[bff_info_key];
|
|
14
14
|
const prefix = bff_info === null || bff_info === void 0 ? void 0 : (_bff_info_modernUserConfig = bff_info.modernUserConfig) === null || _bff_info_modernUserConfig === void 0 ? void 0 : (_bff_info_modernUserConfig_bff = _bff_info_modernUserConfig.bff) === null || _bff_info_modernUserConfig_bff === void 0 ? void 0 : _bff_info_modernUserConfig_bff.prefix;
|
|
15
15
|
const httpMethodDecider = bff_info === null || bff_info === void 0 ? void 0 : (_bff_info_modernUserConfig1 = bff_info.modernUserConfig) === null || _bff_info_modernUserConfig1 === void 0 ? void 0 : (_bff_info_modernUserConfig_bff1 = _bff_info_modernUserConfig1.bff) === null || _bff_info_modernUserConfig_bff1 === void 0 ? void 0 : _bff_info_modernUserConfig_bff1.httpMethodDecider;
|
|
16
|
-
const apiRouter = new ApiRouter({
|
|
17
|
-
apiDir: path.join(bff_info.appDir, "./api"),
|
|
18
|
-
prefix,
|
|
19
|
-
httpMethodDecider
|
|
20
|
-
});
|
|
21
|
-
const apiInfos = apiRouter.getApiHandlers();
|
|
22
|
-
const apiInfosByFile = apiInfos.reduce((res, apiInfo) => {
|
|
23
|
-
if (!res[apiInfo.filename]) {
|
|
24
|
-
res[apiInfo.filename] = [];
|
|
25
|
-
}
|
|
26
|
-
res[apiInfo.filename].push(apiInfo);
|
|
27
|
-
return res;
|
|
28
|
-
}, {});
|
|
29
16
|
let app = null;
|
|
30
17
|
beforeAll(async () => {
|
|
18
|
+
const apiRouter = new ApiRouter({
|
|
19
|
+
apiDir: path.join(bff_info.appDir, "./api"),
|
|
20
|
+
prefix,
|
|
21
|
+
httpMethodDecider
|
|
22
|
+
});
|
|
23
|
+
const apiInfos = apiRouter.getApiHandlers();
|
|
24
|
+
const apiInfosByFile = apiInfos.reduce((res, apiInfo) => {
|
|
25
|
+
if (!res[apiInfo.filename]) {
|
|
26
|
+
res[apiInfo.filename] = [];
|
|
27
|
+
}
|
|
28
|
+
res[apiInfo.filename].push(apiInfo);
|
|
29
|
+
return res;
|
|
30
|
+
}, {});
|
|
31
|
+
mockAPI(apiInfosByFile);
|
|
31
32
|
if (!app) {
|
|
32
33
|
app = await createApp(bff_info.appDir, bff_info.modernUserConfig, bff_info.plugins, bff_info.routes);
|
|
33
34
|
}
|
|
@@ -35,6 +36,5 @@ const setup = () => {
|
|
|
35
36
|
afterAll(async () => {
|
|
36
37
|
await closeServer();
|
|
37
38
|
});
|
|
38
|
-
mockAPI(apiInfosByFile);
|
|
39
39
|
};
|
|
40
40
|
setup();
|
|
@@ -41,6 +41,7 @@ export default () => {
|
|
|
41
41
|
// The module-tools alias configuration is different and more specific than app-tools.
|
|
42
42
|
// So for the time being, the @ alias is configured here.
|
|
43
43
|
"@": path.join(appContext.appDirectory, "src"),
|
|
44
|
+
"@modern-js/runtime/testing/bff": require.resolve("@modern-js/plugin-testing/bff"),
|
|
44
45
|
"@modern-js/runtime/testing": testingExportsUtils.getPath()
|
|
45
46
|
}
|
|
46
47
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import supertest from "supertest";
|
|
2
|
+
import { getApp } from "../cli/bff/app";
|
|
3
|
+
function request(...args) {
|
|
4
|
+
const [fn, ...extraArgs] = args;
|
|
5
|
+
const app = getApp();
|
|
6
|
+
if (!fn) {
|
|
7
|
+
return supertest(app);
|
|
8
|
+
}
|
|
9
|
+
fn.returnHttp = true;
|
|
10
|
+
const res = fn(...extraArgs);
|
|
11
|
+
fn.returnHttp = false;
|
|
12
|
+
return res;
|
|
13
|
+
}
|
|
14
|
+
export { request as testBff };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
var __async = (__this, __arguments, generator) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
var fulfilled = (value) => {
|
|
4
|
+
try {
|
|
5
|
+
step(generator.next(value));
|
|
6
|
+
} catch (e) {
|
|
7
|
+
reject(e);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
var rejected = (value) => {
|
|
11
|
+
try {
|
|
12
|
+
step(generator.throw(value));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
reject(e);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
18
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
import { applyPatches } from "./patches";
|
|
22
|
+
import { TestConfigOperator } from "./testConfigOperator";
|
|
23
|
+
const getJestUtils = (testConfig) => {
|
|
24
|
+
const testOperator = new TestConfigOperator(testConfig);
|
|
25
|
+
return testOperator;
|
|
26
|
+
};
|
|
27
|
+
const patchConfig = (testOperator) => __async(void 0, null, function* () {
|
|
28
|
+
yield applyPatches(testOperator);
|
|
29
|
+
return testOperator.jestConfig;
|
|
30
|
+
});
|
|
31
|
+
const DEFAULT_RESOLVER_PATH = require.resolve("./resolver");
|
|
32
|
+
export {
|
|
33
|
+
DEFAULT_RESOLVER_PATH,
|
|
34
|
+
getJestUtils,
|
|
35
|
+
patchConfig
|
|
36
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const patchAssetsModule = (testOperator) => {
|
|
2
|
+
testOperator.mergeJestConfig({
|
|
3
|
+
moduleNameMapper: {
|
|
4
|
+
"\\.(css|less|scss|sass)$": require.resolve("identity-obj-proxy"),
|
|
5
|
+
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": require.resolve("./filemock.js")
|
|
6
|
+
}
|
|
7
|
+
});
|
|
8
|
+
};
|
|
9
|
+
export {
|
|
10
|
+
patchAssetsModule
|
|
11
|
+
};
|