@modern-js/plugin-testing 1.5.1 → 1.5.4

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 CHANGED
@@ -1,5 +1,40 @@
1
1
  # @modern-js/plugin-testing
2
2
 
3
+ ## 1.5.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 0e0537005: fix: unlock @babel/core version
8
+ - 69a728375: fix: remove exports.jsnext:source after publish
9
+ - Updated dependencies [b7b8075dc]
10
+ - Updated dependencies [cd7346b0d]
11
+ - Updated dependencies [0e0537005]
12
+ - Updated dependencies [738c55d39]
13
+ - Updated dependencies [69a728375]
14
+ - Updated dependencies [0f86e133b]
15
+ - @modern-js/webpack@1.6.2
16
+ - @modern-js/runtime-core@1.4.5
17
+ - @modern-js/utils@1.7.2
18
+ - @modern-js/testing@1.5.1
19
+ - @modern-js/babel-compiler@1.2.4
20
+ - @modern-js/testing-plugin-bff@1.4.2
21
+ - @modern-js/bff-utils@1.2.5
22
+
23
+ ## 1.5.3
24
+
25
+ ### Patch Changes
26
+
27
+ - 3f209269: feat(testing): add `afterTest` hook for testing plugin
28
+ - Updated dependencies [4697d1db]
29
+ - Updated dependencies [0ee4bb4e]
30
+ - Updated dependencies [6fa74d5f]
31
+ - Updated dependencies [3f209269]
32
+ - @modern-js/webpack@1.6.0
33
+ - @modern-js/testing@1.5.0
34
+ - @modern-js/utils@1.7.0
35
+ - @modern-js/runtime-core@1.4.4
36
+ - @modern-js/testing-plugin-bff@1.4.1
37
+
3
38
  ## 1.5.1
4
39
 
5
40
  ### Patch Changes
@@ -1,20 +1,16 @@
1
1
  import path from 'path';
2
2
  import { PLUGIN_SCHEMAS, createRuntimeExportsUtils, isApiOnly } from '@modern-js/utils';
3
- import { jestConfigHook, getModuleNameMapper, DEFAULT_RESOLVER_PATH } from '@modern-js/testing';
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,11 +72,9 @@ 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
- // todo: diffrent test root for diffrent solutions
77
+ // todo: diffrernt test root for diffrent solutions
86
78
  // testMatch: [`<rootDir>/(src|tests|electron)/**/*.test.[jt]s?(x)`],
87
79
  // testMatch bug on windows, issue: https://github.com/facebook/jest/issues/7914
88
80
  testMatch: [`<rootDir>/src/**/*.test.[jt]s?(x)`, `<rootDir>/tests/**/*.test.[jt]s?(x)`, `<rootDir>/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,11 +92,9 @@ 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
- // todo: diffrent test root for diffrent solutions
97
+ // todo: diffrernt test root for diffrent solutions
106
98
  // testMatch: [`<rootDir>/(src|tests|electron)/**/*.test.[jt]s?(x)`],
107
99
  // testMatch bug on windows, issue: https://github.com/facebook/jest/issues/7914
108
100
  testMatch: [`<rootDir>/src/**/*.test.[jt]s?(x)`, `<rootDir>/tests/**/*.test.[jt]s?(x)`, `<rootDir>/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 { jestConfigHook, getModuleNameMapper, DEFAULT_RESOLVER_PATH } from '@modern-js/testing';
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,11 +96,9 @@ 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
- // todo: diffrent test root for diffrent solutions
101
+ // todo: diffrernt test root for diffrent solutions
110
102
  // testMatch: [`<rootDir>/(src|tests|electron)/**/*.test.[jt]s?(x)`],
111
103
  // testMatch bug on windows, issue: https://github.com/facebook/jest/issues/7914
112
104
  testMatch: ["<rootDir>/src/**/*.test.[jt]s?(x)", "<rootDir>/tests/**/*.test.[jt]s?(x)", "<rootDir>/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 13:
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.1",
14
+ "version": "1.5.4",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -78,26 +78,26 @@
78
78
  }
79
79
  },
80
80
  "dependencies": {
81
- "@babel/core": "7.16.7",
81
+ "@babel/core": "^7.17.0",
82
82
  "@babel/preset-env": "^7.15.6",
83
83
  "@babel/runtime": "^7",
84
84
  "@modern-js-reduck/plugin-auto-actions": "^1.0.2",
85
85
  "@modern-js-reduck/plugin-effects": "^1.0.2",
86
86
  "@modern-js-reduck/plugin-immutable": "^1.0.1",
87
87
  "@modern-js-reduck/store": "^1.0.3",
88
- "@modern-js/babel-compiler": "^1.2.3",
89
- "@modern-js/bff-utils": "^1.2.4",
90
- "@modern-js/runtime-core": "^1.4.3",
91
- "@modern-js/testing": "^1.4.4",
92
- "@modern-js/testing-plugin-bff": "^1.4.1",
93
- "@modern-js/utils": "^1.6.0",
94
- "@modern-js/webpack": "^1.5.7",
88
+ "@modern-js/babel-compiler": "^1.2.4",
89
+ "@modern-js/bff-utils": "^1.2.5",
90
+ "@modern-js/runtime-core": "^1.4.5",
91
+ "@modern-js/testing": "^1.5.1",
92
+ "@modern-js/testing-plugin-bff": "^1.4.2",
93
+ "@modern-js/utils": "^1.7.2",
94
+ "@modern-js/webpack": "^1.6.2",
95
95
  "@testing-library/jest-dom": "^5.14.1",
96
96
  "@testing-library/react": "^12.0.0",
97
97
  "@types/testing-library__jest-dom": "^5.14.3"
98
98
  },
99
99
  "devDependencies": {
100
- "@modern-js/core": "1.9.0",
100
+ "@modern-js/core": "1.10.1",
101
101
  "@scripts/build": "0.0.0",
102
102
  "@scripts/jest-config": "0.0.0",
103
103
  "@types/jest": "^26",