@modern-js/plugin-testing 1.5.1 → 1.5.2
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.
@@ -1,20 +1,16 @@
|
|
1
1
|
import path from 'path';
|
2
2
|
import { PLUGIN_SCHEMAS, createRuntimeExportsUtils, isApiOnly } from '@modern-js/utils';
|
3
|
-
import {
|
3
|
+
import { testingHooks, getModuleNameMapper, DEFAULT_RESOLVER_PATH } from '@modern-js/testing';
|
4
4
|
import { getWebpackConfig, WebpackConfigTarget } from '@modern-js/webpack';
|
5
5
|
import TestingBffPlugin from '@modern-js/testing-plugin-bff';
|
6
6
|
import { MODERNJS_CONFIG_KEY } from "../constant";
|
7
7
|
import test from "./test";
|
8
8
|
export const mergeUserJestConfig = testUtils => {
|
9
|
-
const resolveJestConfig = testUtils.testConfig.jest;
|
9
|
+
const resolveJestConfig = testUtils.testConfig.jest; // resolveJestConfig 如果是函数类型,在所有测试插件 jestConfig 都执行后,再执行生成最终配置
|
10
10
|
|
11
11
|
if (resolveJestConfig && typeof resolveJestConfig !== 'function') {
|
12
12
|
testUtils.mergeJestConfig(resolveJestConfig);
|
13
13
|
}
|
14
|
-
|
15
|
-
if (typeof resolveJestConfig === 'function') {
|
16
|
-
resolveJestConfig(testUtils.jestConfig);
|
17
|
-
}
|
18
14
|
};
|
19
15
|
export default (() => {
|
20
16
|
const BffPlugin = TestingBffPlugin();
|
@@ -22,16 +18,14 @@ export default (() => {
|
|
22
18
|
name: '@modern-js/plugin-testing',
|
23
19
|
usePlugins: [BffPlugin],
|
24
20
|
post: [BffPlugin.name],
|
25
|
-
registerHook:
|
26
|
-
jestConfig: jestConfigHook
|
27
|
-
},
|
21
|
+
registerHook: testingHooks,
|
28
22
|
setup: api => {
|
29
23
|
let testingExportsUtils;
|
30
24
|
return {
|
31
25
|
commands: ({
|
32
26
|
program
|
33
27
|
}) => {
|
34
|
-
program.command('test').allowUnknownOption().usage('[options]').action(async () => {
|
28
|
+
program.command('test').allowUnknownOption().usage('<regexForTestFiles> --[options]').action(async () => {
|
35
29
|
await test(api);
|
36
30
|
});
|
37
31
|
},
|
@@ -78,9 +72,7 @@ export default (() => {
|
|
78
72
|
},
|
79
73
|
moduleNameMapper: getModuleNameMapper(alias),
|
80
74
|
testEnvironment: 'jsdom',
|
81
|
-
resolver: DEFAULT_RESOLVER_PATH
|
82
|
-
});
|
83
|
-
utils.setJestConfig({
|
75
|
+
resolver: DEFAULT_RESOLVER_PATH,
|
84
76
|
rootDir: appContext.appDirectory || process.cwd(),
|
85
77
|
// todo: diffrent test root for diffrent solutions
|
86
78
|
// testMatch: [`<rootDir>/(src|tests|electron)/**/*.test.[jt]s?(x)`],
|
@@ -22,15 +22,11 @@ var _test = _interopRequireDefault(require("./test"));
|
|
22
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
23
23
|
|
24
24
|
const mergeUserJestConfig = testUtils => {
|
25
|
-
const resolveJestConfig = testUtils.testConfig.jest;
|
25
|
+
const resolveJestConfig = testUtils.testConfig.jest; // resolveJestConfig 如果是函数类型,在所有测试插件 jestConfig 都执行后,再执行生成最终配置
|
26
26
|
|
27
27
|
if (resolveJestConfig && typeof resolveJestConfig !== 'function') {
|
28
28
|
testUtils.mergeJestConfig(resolveJestConfig);
|
29
29
|
}
|
30
|
-
|
31
|
-
if (typeof resolveJestConfig === 'function') {
|
32
|
-
resolveJestConfig(testUtils.jestConfig);
|
33
|
-
}
|
34
30
|
};
|
35
31
|
|
36
32
|
exports.mergeUserJestConfig = mergeUserJestConfig;
|
@@ -41,16 +37,14 @@ var _default = () => {
|
|
41
37
|
name: '@modern-js/plugin-testing',
|
42
38
|
usePlugins: [BffPlugin],
|
43
39
|
post: [BffPlugin.name],
|
44
|
-
registerHook:
|
45
|
-
jestConfig: _testing.jestConfigHook
|
46
|
-
},
|
40
|
+
registerHook: _testing.testingHooks,
|
47
41
|
setup: api => {
|
48
42
|
let testingExportsUtils;
|
49
43
|
return {
|
50
44
|
commands: ({
|
51
45
|
program
|
52
46
|
}) => {
|
53
|
-
program.command('test').allowUnknownOption().usage('[options]').action(async () => {
|
47
|
+
program.command('test').allowUnknownOption().usage('<regexForTestFiles> --[options]').action(async () => {
|
54
48
|
await (0, _test.default)(api);
|
55
49
|
});
|
56
50
|
},
|
@@ -98,9 +92,7 @@ var _default = () => {
|
|
98
92
|
},
|
99
93
|
moduleNameMapper: (0, _testing.getModuleNameMapper)(alias),
|
100
94
|
testEnvironment: 'jsdom',
|
101
|
-
resolver: _testing.DEFAULT_RESOLVER_PATH
|
102
|
-
});
|
103
|
-
utils.setJestConfig({
|
95
|
+
resolver: _testing.DEFAULT_RESOLVER_PATH,
|
104
96
|
rootDir: appContext.appDirectory || process.cwd(),
|
105
97
|
// todo: diffrent test root for diffrent solutions
|
106
98
|
// testMatch: [`<rootDir>/(src|tests|electron)/**/*.test.[jt]s?(x)`],
|
@@ -8,21 +8,17 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
|
|
8
8
|
|
9
9
|
import path from 'path';
|
10
10
|
import { PLUGIN_SCHEMAS, createRuntimeExportsUtils, isApiOnly } from '@modern-js/utils';
|
11
|
-
import {
|
11
|
+
import { testingHooks, getModuleNameMapper, DEFAULT_RESOLVER_PATH } from '@modern-js/testing';
|
12
12
|
import { getWebpackConfig, WebpackConfigTarget } from '@modern-js/webpack';
|
13
13
|
import TestingBffPlugin from '@modern-js/testing-plugin-bff';
|
14
14
|
import { MODERNJS_CONFIG_KEY } from "../constant";
|
15
15
|
import test from "./test";
|
16
16
|
export var mergeUserJestConfig = function mergeUserJestConfig(testUtils) {
|
17
|
-
var resolveJestConfig = testUtils.testConfig.jest;
|
17
|
+
var resolveJestConfig = testUtils.testConfig.jest; // resolveJestConfig 如果是函数类型,在所有测试插件 jestConfig 都执行后,再执行生成最终配置
|
18
18
|
|
19
19
|
if (resolveJestConfig && typeof resolveJestConfig !== 'function') {
|
20
20
|
testUtils.mergeJestConfig(resolveJestConfig);
|
21
21
|
}
|
22
|
-
|
23
|
-
if (typeof resolveJestConfig === 'function') {
|
24
|
-
resolveJestConfig(testUtils.jestConfig);
|
25
|
-
}
|
26
22
|
};
|
27
23
|
export default (function () {
|
28
24
|
var BffPlugin = TestingBffPlugin();
|
@@ -30,15 +26,13 @@ export default (function () {
|
|
30
26
|
name: '@modern-js/plugin-testing',
|
31
27
|
usePlugins: [BffPlugin],
|
32
28
|
post: [BffPlugin.name],
|
33
|
-
registerHook:
|
34
|
-
jestConfig: jestConfigHook
|
35
|
-
},
|
29
|
+
registerHook: testingHooks,
|
36
30
|
setup: function setup(api) {
|
37
31
|
var testingExportsUtils;
|
38
32
|
return {
|
39
33
|
commands: function commands(_ref) {
|
40
34
|
var program = _ref.program;
|
41
|
-
program.command('test').allowUnknownOption().usage('[options]').action( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
35
|
+
program.command('test').allowUnknownOption().usage('<regexForTestFiles> --[options]').action( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
42
36
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
43
37
|
while (1) {
|
44
38
|
switch (_context.prev = _context.next) {
|
@@ -102,9 +96,7 @@ export default (function () {
|
|
102
96
|
globals: _defineProperty({}, MODERNJS_CONFIG_KEY, userConfig),
|
103
97
|
moduleNameMapper: getModuleNameMapper(alias),
|
104
98
|
testEnvironment: 'jsdom',
|
105
|
-
resolver: DEFAULT_RESOLVER_PATH
|
106
|
-
});
|
107
|
-
utils.setJestConfig({
|
99
|
+
resolver: DEFAULT_RESOLVER_PATH,
|
108
100
|
rootDir: appContext.appDirectory || process.cwd(),
|
109
101
|
// todo: diffrent test root for diffrent solutions
|
110
102
|
// testMatch: [`<rootDir>/(src|tests|electron)/**/*.test.[jt]s?(x)`],
|
@@ -114,7 +106,7 @@ export default (function () {
|
|
114
106
|
mergeUserJestConfig(utils);
|
115
107
|
return _context2.abrupt("return", next(utils));
|
116
108
|
|
117
|
-
case
|
109
|
+
case 12:
|
118
110
|
case "end":
|
119
111
|
return _context2.stop();
|
120
112
|
}
|
package/package.json
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
"modern",
|
12
12
|
"modern.js"
|
13
13
|
],
|
14
|
-
"version": "1.5.
|
14
|
+
"version": "1.5.2",
|
15
15
|
"jsnext:source": "./src/index.ts",
|
16
16
|
"types": "./dist/types/index.d.ts",
|
17
17
|
"main": "./dist/js/node/index.js",
|
@@ -113,13 +113,13 @@
|
|
113
113
|
"modernConfig": {},
|
114
114
|
"publishConfig": {
|
115
115
|
"registry": "https://registry.npmjs.org/",
|
116
|
-
"access": "public"
|
116
|
+
"access": "public",
|
117
|
+
"types": "./dist/types/index.d.ts"
|
117
118
|
},
|
118
119
|
"scripts": {
|
119
120
|
"new": "modern new",
|
120
121
|
"dev": "modern build --watch",
|
121
122
|
"build": "modern build",
|
122
123
|
"test": "jest --passWithNoTests"
|
123
|
-
}
|
124
|
-
"readme": "\n<p align=\"center\">\n <a href=\"https://modernjs.dev\" target=\"blank\"><img src=\"https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png\" width=\"300\" alt=\"Modern.js Logo\" /></a>\n</p>\n<p align=\"center\">\n现代 Web 工程体系\n <br/>\n <a href=\"https://modernjs.dev\" target=\"blank\">\n modernjs.dev\n </a>\n</p>\n<p align=\"center\">\n The meta-framework suite designed from scratch for frontend-focused modern web development\n</p>\n\n# Introduction\n\n> The doc site ([modernjs.dev](https://modernjs.dev)) and articles are only available in Chinese for now, we are planning to add English versions soon.\n\n- [Modern.js: Hello, World!](https://zhuanlan.zhihu.com/p/426707646)\n\n## Getting Started\n\n- [Quick Start](https://modernjs.dev/docs/start)\n- [Guides](https://modernjs.dev/docs/guides)\n- [API References](https://modernjs.dev/docs/apis)\n\n## Contributing\n\n- [Contributing Guide](https://github.com/modern-js-dev/modern.js/blob/main/CONTRIBUTING.md)\n"
|
124
|
+
}
|
125
125
|
}
|