@modern-js/plugin-testing 1.7.1-beta.0 → 1.7.1-beta.1
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/dist/js/modern/cli/bff/index.js +2 -5
- package/dist/js/modern/cli/bff/mockAPI.js +0 -1
- package/dist/js/modern/cli/bff/setup.js +1 -2
- package/dist/js/modern/runtime-testing/request.js +3 -1
- package/dist/js/node/cli/bff/index.js +2 -5
- package/dist/js/node/cli/bff/mockAPI.js +0 -1
- package/dist/js/node/cli/bff/setup.js +1 -2
- package/dist/js/node/runtime-testing/request.js +4 -1
- package/dist/js/treeshaking/cli/bff/index.js +5 -9
- package/dist/js/treeshaking/cli/bff/mockAPI.js +0 -1
- package/dist/js/treeshaking/cli/bff/setup.js +1 -2
- package/dist/js/treeshaking/runtime-testing/request.js +3 -1
- package/package.json +2 -2
@@ -38,12 +38,9 @@ export const setJestConfigForBFF = async ({
|
|
38
38
|
const alias = (userConfig === null || userConfig === void 0 ? void 0 : (_userConfig$source = userConfig.source) === null || _userConfig$source === void 0 ? void 0 : _userConfig$source.alias) || {};
|
39
39
|
const aliasMapper = getModuleNameMapper(alias);
|
40
40
|
const {
|
41
|
+
transform,
|
41
42
|
moduleNameMapper
|
42
|
-
} = jestConfig;
|
43
|
-
|
44
|
-
const transform = {
|
45
|
-
'\\.[jt]sx?$': require.resolve('ts-jest')
|
46
|
-
};
|
43
|
+
} = jestConfig;
|
47
44
|
const apiOnly = await isApiOnly(pwd);
|
48
45
|
|
49
46
|
const mergedModuleNameMapper = _objectSpread(_objectSpread({}, moduleNameMapper), aliasMapper);
|
@@ -48,7 +48,6 @@ export default (mockApiInfosByFile => {
|
|
48
48
|
const files = Object.keys(mockApiInfosByFile);
|
49
49
|
files.forEach(mockedFile => {
|
50
50
|
jest.mock(mockedFile, () => {
|
51
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
52
51
|
const supertest = require('supertest');
|
53
52
|
|
54
53
|
return mockApiInfosByFile[mockedFile].reduce((res, info) => {
|
@@ -4,7 +4,6 @@ import { bff_info_key } from "./constant";
|
|
4
4
|
import mockAPI from "./mockAPI";
|
5
5
|
import { createApp, closeServer } from "./app";
|
6
6
|
let uped = false;
|
7
|
-
const BEFORE_ALL_TIMEOUT = 30000;
|
8
7
|
|
9
8
|
const setup = () => {
|
10
9
|
var _bff_info$modernUserC, _bff_info$modernUserC2;
|
@@ -34,7 +33,7 @@ const setup = () => {
|
|
34
33
|
if (!app) {
|
35
34
|
app = await createApp(bff_info.appDir, bff_info.modernUserConfig, bff_info.plugins, bff_info.routes);
|
36
35
|
}
|
37
|
-
}
|
36
|
+
});
|
38
37
|
afterAll(async () => {
|
39
38
|
await closeServer();
|
40
39
|
});
|
@@ -1,11 +1,13 @@
|
|
1
1
|
/* eslint-disable eslint-comments/disable-enable-pair */
|
2
2
|
import supertest from 'supertest';
|
3
|
+
import { getApp } from "../cli/bff/app";
|
3
4
|
|
4
5
|
function request(...args) {
|
5
6
|
const [fn, ...extraArgs] = args;
|
7
|
+
const app = getApp();
|
6
8
|
|
7
9
|
if (!fn) {
|
8
|
-
return supertest(
|
10
|
+
return supertest(app);
|
9
11
|
}
|
10
12
|
|
11
13
|
fn.returnHttp = true;
|
@@ -52,12 +52,9 @@ const setJestConfigForBFF = async ({
|
|
52
52
|
const alias = (userConfig === null || userConfig === void 0 ? void 0 : (_userConfig$source = userConfig.source) === null || _userConfig$source === void 0 ? void 0 : _userConfig$source.alias) || {};
|
53
53
|
const aliasMapper = (0, _base.getModuleNameMapper)(alias);
|
54
54
|
const {
|
55
|
+
transform,
|
55
56
|
moduleNameMapper
|
56
|
-
} = jestConfig;
|
57
|
-
|
58
|
-
const transform = {
|
59
|
-
'\\.[jt]sx?$': require.resolve('ts-jest')
|
60
|
-
};
|
57
|
+
} = jestConfig;
|
61
58
|
const apiOnly = await (0, _utils.isApiOnly)(pwd);
|
62
59
|
|
63
60
|
const mergedModuleNameMapper = _objectSpread(_objectSpread({}, moduleNameMapper), aliasMapper);
|
@@ -61,7 +61,6 @@ var _default = mockApiInfosByFile => {
|
|
61
61
|
const files = Object.keys(mockApiInfosByFile);
|
62
62
|
files.forEach(mockedFile => {
|
63
63
|
jest.mock(mockedFile, () => {
|
64
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
65
64
|
const supertest = require('supertest');
|
66
65
|
|
67
66
|
return mockApiInfosByFile[mockedFile].reduce((res, info) => {
|
@@ -13,7 +13,6 @@ var _app = require("./app");
|
|
13
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
14
14
|
|
15
15
|
let uped = false;
|
16
|
-
const BEFORE_ALL_TIMEOUT = 30000;
|
17
16
|
|
18
17
|
const setup = () => {
|
19
18
|
var _bff_info$modernUserC, _bff_info$modernUserC2;
|
@@ -43,7 +42,7 @@ const setup = () => {
|
|
43
42
|
if (!app) {
|
44
43
|
app = await (0, _app.createApp)(bff_info.appDir, bff_info.modernUserConfig, bff_info.plugins, bff_info.routes);
|
45
44
|
}
|
46
|
-
}
|
45
|
+
});
|
47
46
|
afterAll(async () => {
|
48
47
|
await (0, _app.closeServer)();
|
49
48
|
});
|
@@ -7,14 +7,17 @@ exports.request = request;
|
|
7
7
|
|
8
8
|
var _supertest = _interopRequireDefault(require("supertest"));
|
9
9
|
|
10
|
+
var _app = require("../cli/bff/app");
|
11
|
+
|
10
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
11
13
|
|
12
14
|
/* eslint-disable eslint-comments/disable-enable-pair */
|
13
15
|
function request(...args) {
|
14
16
|
const [fn, ...extraArgs] = args;
|
17
|
+
const app = (0, _app.getApp)();
|
15
18
|
|
16
19
|
if (!fn) {
|
17
|
-
return (0, _supertest.default)(
|
20
|
+
return (0, _supertest.default)(app);
|
18
21
|
}
|
19
22
|
|
20
23
|
fn.returnHttp = true;
|
@@ -11,7 +11,7 @@ export var setJestConfigForBFF = /*#__PURE__*/function () {
|
|
11
11
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
12
12
|
var _userConfig$source;
|
13
13
|
|
14
|
-
var pwd, userConfig, plugins, routes, utils, bffConfig, jestConfig, alias, aliasMapper,
|
14
|
+
var pwd, userConfig, plugins, routes, utils, bffConfig, jestConfig, alias, aliasMapper, transform, moduleNameMapper, apiOnly, mergedModuleNameMapper, resolver, configFields, commonConfig;
|
15
15
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
16
16
|
while (1) {
|
17
17
|
switch (_context.prev = _context.next) {
|
@@ -32,15 +32,11 @@ export var setJestConfigForBFF = /*#__PURE__*/function () {
|
|
32
32
|
jestConfig = utils.jestConfig;
|
33
33
|
alias = (userConfig === null || userConfig === void 0 ? void 0 : (_userConfig$source = userConfig.source) === null || _userConfig$source === void 0 ? void 0 : _userConfig$source.alias) || {};
|
34
34
|
aliasMapper = getModuleNameMapper(alias);
|
35
|
-
moduleNameMapper = jestConfig.moduleNameMapper;
|
36
|
-
|
37
|
-
transform = {
|
38
|
-
'\\.[jt]sx?$': require.resolve('ts-jest')
|
39
|
-
};
|
40
|
-
_context.next = 9;
|
35
|
+
transform = jestConfig.transform, moduleNameMapper = jestConfig.moduleNameMapper;
|
36
|
+
_context.next = 8;
|
41
37
|
return isApiOnly(pwd);
|
42
38
|
|
43
|
-
case
|
39
|
+
case 8:
|
44
40
|
apiOnly = _context.sent;
|
45
41
|
mergedModuleNameMapper = _objectSpread(_objectSpread({}, moduleNameMapper), aliasMapper);
|
46
42
|
resolver = jestConfig.resolver || DEFAULT_RESOLVER_PATH; // 这三个配置不能设置在 projects 中,需要设置在外层(https://github.com/facebook/jest/issues/9696)
|
@@ -78,7 +74,7 @@ export var setJestConfigForBFF = /*#__PURE__*/function () {
|
|
78
74
|
|
79
75
|
utils.setJestConfig(commonConfig);
|
80
76
|
|
81
|
-
case
|
77
|
+
case 15:
|
82
78
|
case "end":
|
83
79
|
return _context.stop();
|
84
80
|
}
|
@@ -46,7 +46,6 @@ export default (function (mockApiInfosByFile) {
|
|
46
46
|
var files = Object.keys(mockApiInfosByFile);
|
47
47
|
files.forEach(function (mockedFile) {
|
48
48
|
jest.mock(mockedFile, function () {
|
49
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
50
49
|
var supertest = require('supertest');
|
51
50
|
|
52
51
|
return mockApiInfosByFile[mockedFile].reduce(function (res, info) {
|
@@ -6,7 +6,6 @@ import { bff_info_key } from "./constant";
|
|
6
6
|
import mockAPI from "./mockAPI";
|
7
7
|
import { createApp, closeServer } from "./app";
|
8
8
|
var uped = false;
|
9
|
-
var BEFORE_ALL_TIMEOUT = 30000;
|
10
9
|
|
11
10
|
var setup = function setup() {
|
12
11
|
var _bff_info$modernUserC, _bff_info$modernUserC2;
|
@@ -54,7 +53,7 @@ var setup = function setup() {
|
|
54
53
|
}
|
55
54
|
}
|
56
55
|
}, _callee);
|
57
|
-
}))
|
56
|
+
})));
|
58
57
|
afterAll( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
59
58
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
60
59
|
while (1) {
|
@@ -2,6 +2,7 @@ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
2
|
|
3
3
|
/* eslint-disable eslint-comments/disable-enable-pair */
|
4
4
|
import supertest from 'supertest';
|
5
|
+
import { getApp } from "../cli/bff/app";
|
5
6
|
|
6
7
|
function request() {
|
7
8
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
@@ -10,9 +11,10 @@ function request() {
|
|
10
11
|
|
11
12
|
var fn = args[0],
|
12
13
|
extraArgs = args.slice(1);
|
14
|
+
var app = getApp();
|
13
15
|
|
14
16
|
if (!fn) {
|
15
|
-
return supertest(
|
17
|
+
return supertest(app);
|
16
18
|
}
|
17
19
|
|
18
20
|
fn.returnHttp = true;
|
package/package.json
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
"modern",
|
12
12
|
"modern.js"
|
13
13
|
],
|
14
|
-
"version": "1.7.1-beta.
|
14
|
+
"version": "1.7.1-beta.1",
|
15
15
|
"jsnext:source": "./src/index.ts",
|
16
16
|
"types": "./dist/types/index.d.ts",
|
17
17
|
"main": "./dist/js/node/index.js",
|
@@ -129,7 +129,7 @@
|
|
129
129
|
"devDependencies": {
|
130
130
|
"@modern-js/core": "1.13.3",
|
131
131
|
"@modern-js/runtime": "1.4.4",
|
132
|
-
"@modern-js/bff-core": "1.2.1",
|
132
|
+
"@modern-js/bff-core": "1.2.2-beta.1",
|
133
133
|
"@scripts/build": "0.0.0",
|
134
134
|
"@scripts/jest-config": "0.0.0",
|
135
135
|
"@types/jest": "^27",
|