@modern-js/plugin-testing 1.1.2 → 1.1.3

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.
@@ -41,7 +41,8 @@ export default ((webpackConfig, userConfig, pwd) => createPlugin(() => ({
41
41
  utils.setJestConfig({
42
42
  rootDir: pwd || process.cwd(),
43
43
  // todo: diffrent test root for diffrent solutions
44
- testMatch: [`**/(src|tests|api|electron)/**/*.test.[jt]s?(x)`]
44
+ // testMatch: [`<rootDir>/(src|tests|electron)/**/*.test.[jt]s?(x)`],
45
+ testMatch: [`<rootDir>/src/**/*.test.[jt]s?(x)`, `<rootDir>/tests/**/*.test.[jt]s?(x)`, `<rootDir>/electron/**/*.test.[jt]s?(x)`]
45
46
  });
46
47
  return next(utils);
47
48
  }
@@ -2,8 +2,8 @@ import path from 'path';
2
2
  import { compiler } from '@modern-js/babel-compiler';
3
3
  import { useAppContext, useResolvedConfigContext } from '@modern-js/core';
4
4
  import { runTest } from '@modern-js/testing';
5
- import { getWebpackConfig, WebpackConfigTarget } from '@modern-js/webpack'; // import testingBffPlugin from '@modern-js/testing-plugin-bff';
6
-
5
+ import { getWebpackConfig, WebpackConfigTarget } from '@modern-js/webpack';
6
+ import testingBffPlugin from '@modern-js/testing-plugin-bff';
7
7
  import modernTestPlugin from "./plugins/modern";
8
8
 
9
9
  const test = async () => {
@@ -15,13 +15,12 @@ const test = async () => {
15
15
  const webpackConfigs = getWebpackConfig(WebpackConfigTarget.CLIENT);
16
16
  userConfig.testing = userConfig.testing || {};
17
17
  userConfig.testing.jest = userConfig.testing.jest || userConfig.tools.jest;
18
- userConfig.testing.plugins = [...(userConfig.testing.plugins || []), modernTestPlugin(webpackConfigs, userConfig, config.appDirectory) // testingBffPlugin({
19
- // pwd: config.appDirectory,
20
- // userConfig: userConfig,
21
- // plugins: config.plugins.map(p => p.server).filter(Boolean),
22
- // routes: (config as any).serverRoutes
23
- // }),
24
- ];
18
+ userConfig.testing.plugins = [...(userConfig.testing.plugins || []), modernTestPlugin(webpackConfigs, userConfig, config.appDirectory), testingBffPlugin({
19
+ pwd: config.appDirectory,
20
+ userConfig,
21
+ plugins: config.plugins.map(p => p.server).filter(Boolean),
22
+ routes: config.serverRoutes
23
+ })];
25
24
  const runtimeExportsPath = path.join(config.internalDirectory, '.runtime-exports');
26
25
  await compiler({
27
26
  sourceDir: runtimeExportsPath,
@@ -1,3 +1,4 @@
1
1
  export { default as renderApp } from "./customRender";
2
2
  export * from '@testing-library/react';
3
- export * from "./reduck"; // export { testBff } from '@modern-js/testing-plugin-bff';
3
+ export * from "./reduck";
4
+ export { testBff } from '@modern-js/testing-plugin-bff';
@@ -54,7 +54,8 @@ var _default = (webpackConfig, userConfig, pwd) => (0, _testing.createPlugin)(()
54
54
  utils.setJestConfig({
55
55
  rootDir: pwd || process.cwd(),
56
56
  // todo: diffrent test root for diffrent solutions
57
- testMatch: [`**/(src|tests|api|electron)/**/*.test.[jt]s?(x)`]
57
+ // testMatch: [`<rootDir>/(src|tests|electron)/**/*.test.[jt]s?(x)`],
58
+ testMatch: [`<rootDir>/src/**/*.test.[jt]s?(x)`, `<rootDir>/tests/**/*.test.[jt]s?(x)`, `<rootDir>/electron/**/*.test.[jt]s?(x)`]
58
59
  });
59
60
  return next(utils);
60
61
  }
@@ -15,11 +15,12 @@ var _testing = require("@modern-js/testing");
15
15
 
16
16
  var _webpack = require("@modern-js/webpack");
17
17
 
18
+ var _testingPluginBff = _interopRequireDefault(require("@modern-js/testing-plugin-bff"));
19
+
18
20
  var _modern = _interopRequireDefault(require("./plugins/modern"));
19
21
 
20
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
23
 
22
- // import testingBffPlugin from '@modern-js/testing-plugin-bff';
23
24
  const test = async () => {
24
25
  // eslint-disable-next-line react-hooks/rules-of-hooks
25
26
  const userConfig = (0, _core.useResolvedConfigContext)(); // eslint-disable-next-line react-hooks/rules-of-hooks
@@ -29,13 +30,12 @@ const test = async () => {
29
30
  const webpackConfigs = (0, _webpack.getWebpackConfig)(_webpack.WebpackConfigTarget.CLIENT);
30
31
  userConfig.testing = userConfig.testing || {};
31
32
  userConfig.testing.jest = userConfig.testing.jest || userConfig.tools.jest;
32
- userConfig.testing.plugins = [...(userConfig.testing.plugins || []), (0, _modern.default)(webpackConfigs, userConfig, config.appDirectory) // testingBffPlugin({
33
- // pwd: config.appDirectory,
34
- // userConfig: userConfig,
35
- // plugins: config.plugins.map(p => p.server).filter(Boolean),
36
- // routes: (config as any).serverRoutes
37
- // }),
38
- ];
33
+ userConfig.testing.plugins = [...(userConfig.testing.plugins || []), (0, _modern.default)(webpackConfigs, userConfig, config.appDirectory), (0, _testingPluginBff.default)({
34
+ pwd: config.appDirectory,
35
+ userConfig,
36
+ plugins: config.plugins.map(p => p.server).filter(Boolean),
37
+ routes: config.serverRoutes
38
+ })];
39
39
 
40
40
  const runtimeExportsPath = _path.default.join(config.internalDirectory, '.runtime-exports');
41
41
 
@@ -4,7 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  var _exportNames = {
7
- renderApp: true
7
+ renderApp: true,
8
+ testBff: true
8
9
  };
9
10
  Object.defineProperty(exports, "renderApp", {
10
11
  enumerable: true,
@@ -12,6 +13,12 @@ Object.defineProperty(exports, "renderApp", {
12
13
  return _customRender.default;
13
14
  }
14
15
  });
16
+ Object.defineProperty(exports, "testBff", {
17
+ enumerable: true,
18
+ get: function () {
19
+ return _testingPluginBff.testBff;
20
+ }
21
+ });
15
22
 
16
23
  var _customRender = _interopRequireDefault(require("./customRender"));
17
24
 
@@ -43,4 +50,6 @@ Object.keys(_reduck).forEach(function (key) {
43
50
  });
44
51
  });
45
52
 
53
+ var _testingPluginBff = require("@modern-js/testing-plugin-bff");
54
+
46
55
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -42,7 +42,8 @@ export default (function (webpackConfig, userConfig, pwd) {
42
42
  utils.setJestConfig({
43
43
  rootDir: pwd || process.cwd(),
44
44
  // todo: diffrent test root for diffrent solutions
45
- testMatch: ["**/(src|tests|api|electron)/**/*.test.[jt]s?(x)"]
45
+ // testMatch: [`<rootDir>/(src|tests|electron)/**/*.test.[jt]s?(x)`],
46
+ testMatch: ["<rootDir>/src/**/*.test.[jt]s?(x)", "<rootDir>/tests/**/*.test.[jt]s?(x)", "<rootDir>/electron/**/*.test.[jt]s?(x)"]
46
47
  });
47
48
  return next(utils);
48
49
  }
@@ -20,8 +20,8 @@ import path from 'path';
20
20
  import { compiler } from '@modern-js/babel-compiler';
21
21
  import { useAppContext, useResolvedConfigContext } from '@modern-js/core';
22
22
  import { runTest } from '@modern-js/testing';
23
- import { getWebpackConfig, WebpackConfigTarget } from '@modern-js/webpack'; // import testingBffPlugin from '@modern-js/testing-plugin-bff';
24
-
23
+ import { getWebpackConfig, WebpackConfigTarget } from '@modern-js/webpack';
24
+ import testingBffPlugin from '@modern-js/testing-plugin-bff';
25
25
  import modernTestPlugin from "./plugins/modern";
26
26
 
27
27
  var test = /*#__PURE__*/function () {
@@ -39,13 +39,14 @@ var test = /*#__PURE__*/function () {
39
39
  webpackConfigs = getWebpackConfig(WebpackConfigTarget.CLIENT);
40
40
  userConfig.testing = userConfig.testing || {};
41
41
  userConfig.testing.jest = userConfig.testing.jest || userConfig.tools.jest;
42
- userConfig.testing.plugins = [].concat(_toConsumableArray(userConfig.testing.plugins || []), [modernTestPlugin(webpackConfigs, userConfig, config.appDirectory) // testingBffPlugin({
43
- // pwd: config.appDirectory,
44
- // userConfig: userConfig,
45
- // plugins: config.plugins.map(p => p.server).filter(Boolean),
46
- // routes: (config as any).serverRoutes
47
- // }),
48
- ]);
42
+ userConfig.testing.plugins = [].concat(_toConsumableArray(userConfig.testing.plugins || []), [modernTestPlugin(webpackConfigs, userConfig, config.appDirectory), testingBffPlugin({
43
+ pwd: config.appDirectory,
44
+ userConfig: userConfig,
45
+ plugins: config.plugins.map(function (p) {
46
+ return p.server;
47
+ }).filter(Boolean),
48
+ routes: config.serverRoutes
49
+ })]);
49
50
  runtimeExportsPath = path.join(config.internalDirectory, '.runtime-exports');
50
51
  _context.next = 9;
51
52
  return compiler({
@@ -1,3 +1,4 @@
1
1
  export { default as renderApp } from "./customRender";
2
2
  export * from '@testing-library/react';
3
- export * from "./reduck"; // export { testBff } from '@modern-js/testing-plugin-bff';
3
+ export * from "./reduck";
4
+ export { testBff } from '@modern-js/testing-plugin-bff';
@@ -1,2 +1,10 @@
1
1
  declare const test: () => Promise<void>;
2
- export default test;
2
+ export default test;
3
+ declare module '@modern-js/core' {
4
+ interface UserConfig {
5
+ testing?: import('@modern-js/testing').TestConfig;
6
+ }
7
+ interface ToolsConfig {
8
+ jest?: import('@modern-js/testing').TestConfig['jest'];
9
+ }
10
+ }
@@ -1,3 +1,4 @@
1
1
  export { default as renderApp } from './customRender';
2
2
  export * from '@testing-library/react';
3
- export * from './reduck';
3
+ export * from './reduck';
4
+ export { testBff } from '@modern-js/testing-plugin-bff';
package/package.json CHANGED
@@ -11,19 +11,42 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.1.2",
14
+ "version": "1.1.3",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
18
18
  "module": "./dist/js/treeshaking/index.js",
19
19
  "jsnext:modern": "./dist/js/modern/index.js",
20
20
  "exports": {
21
+ "./type": "./type.d.ts",
22
+ ".": {
23
+ "node": {
24
+ "import": "./dist/js/modern/runtime-testing/index.js",
25
+ "require": "./dist/js/node/runtime-testing/index.js",
26
+ "types": "./types/index.d.ts"
27
+ },
28
+ "default": "./dist/js/treeshaking/runtime-testing/index.js"
29
+ },
30
+ "./runtime": {
31
+ "node": {
32
+ "import": "./dist/js/modern/runtime-testing/index.js",
33
+ "require": "./dist/js/node/runtime-testing/index.js",
34
+ "types": "./types/index.d.ts"
35
+ },
36
+ "default": "./dist/js/treeshaking/runtime/index.js"
37
+ },
21
38
  "./cli": "./dist/js/node/cli/index.js"
22
39
  },
23
40
  "typesVersions": {
24
41
  "*": {
25
42
  ".": [
26
- "./dist/types/index.d.ts"
43
+ "./dist/types/runtime/index.d.ts"
44
+ ],
45
+ "cli": [
46
+ "./dist/types/cli/index.d.ts"
47
+ ],
48
+ "runtime": [
49
+ "./dist/types/runtime-testing/index.d.ts"
27
50
  ],
28
51
  "type": [
29
52
  "./type.d.ts"
@@ -33,21 +56,22 @@
33
56
  "dependencies": {
34
57
  "@babel/preset-env": "^7.15.6",
35
58
  "@babel/runtime": "^7",
36
- "@modern-js/babel-compiler": "^1.1.2",
37
- "@modern-js/testing": "^1.1.1",
38
- "@modern-js/utils": "^1.1.2",
39
- "@modern-js/webpack": "^1.1.2",
59
+ "@modern-js/babel-compiler": "^1.0.0",
60
+ "@modern-js/testing": "^1.0.0",
61
+ "@modern-js/utils": "^1.0.0",
62
+ "@modern-js/webpack": "^1.0.0",
40
63
  "@testing-library/jest-dom": "^5.14.1",
41
64
  "@testing-library/react": "^12.0.0",
42
- "enhanced-resolve": "^5.8.2"
65
+ "enhanced-resolve": "^5.8.2",
66
+ "@modern-js/testing-plugin-bff": "^1.1.1"
43
67
  },
44
68
  "peerDependencies": {
45
69
  "@modern-js-reduck/plugin-auto-actions": "^1.0.0",
46
70
  "@modern-js-reduck/plugin-effects": "^1.0.0",
47
71
  "@modern-js-reduck/plugin-immutable": "^1.0.0",
48
72
  "@modern-js-reduck/store": "^1.0.0",
49
- "@modern-js/core": "^1.1.2",
50
- "@modern-js/runtime-core": "^1.1.1"
73
+ "@modern-js/core": "^1.0.0",
74
+ "@modern-js/runtime-core": "^1.0.0"
51
75
  },
52
76
  "devDependencies": {
53
77
  "@modern-js-reduck/plugin-auto-actions": "^1.0.0",
@@ -56,8 +80,8 @@
56
80
  "@modern-js-reduck/store": "^1.0.0",
57
81
  "@modern-js/plugin-testing": "^1.1.1",
58
82
  "@modern-js/module-tools": "^1.1.1",
59
- "@modern-js/core": "^1.1.2",
60
- "@modern-js/runtime-core": "^1.1.1",
83
+ "@modern-js/core": "^1.0.0",
84
+ "@modern-js/runtime-core": "^1.0.0",
61
85
  "@types/jest": "^26",
62
86
  "@types/node": "^14",
63
87
  "@types/react": "^17",
@@ -46,7 +46,12 @@ export default (webpackConfig: any, userConfig: any, pwd: string) =>
46
46
  utils.setJestConfig({
47
47
  rootDir: pwd || process.cwd(),
48
48
  // todo: diffrent test root for diffrent solutions
49
- testMatch: [`**/(src|tests|api|electron)/**/*.test.[jt]s?(x)`],
49
+ // testMatch: [`<rootDir>/(src|tests|electron)/**/*.test.[jt]s?(x)`],
50
+ testMatch: [
51
+ `<rootDir>/src/**/*.test.[jt]s?(x)`,
52
+ `<rootDir>/tests/**/*.test.[jt]s?(x)`,
53
+ `<rootDir>/electron/**/*.test.[jt]s?(x)`,
54
+ ],
50
55
  });
51
56
 
52
57
  return next(utils);
package/src/cli/test.ts CHANGED
@@ -3,7 +3,7 @@ import { compiler } from '@modern-js/babel-compiler';
3
3
  import { useAppContext, useResolvedConfigContext } from '@modern-js/core';
4
4
  import { runTest } from '@modern-js/testing';
5
5
  import { getWebpackConfig, WebpackConfigTarget } from '@modern-js/webpack';
6
- // import testingBffPlugin from '@modern-js/testing-plugin-bff';
6
+ import testingBffPlugin from '@modern-js/testing-plugin-bff';
7
7
  import modernTestPlugin from './plugins/modern';
8
8
 
9
9
  const test = async () => {
@@ -22,12 +22,12 @@ const test = async () => {
22
22
  userConfig.testing.plugins = [
23
23
  ...(userConfig.testing.plugins || []),
24
24
  modernTestPlugin(webpackConfigs, userConfig, config.appDirectory),
25
- // testingBffPlugin({
26
- // pwd: config.appDirectory,
27
- // userConfig: userConfig,
28
- // plugins: config.plugins.map(p => p.server).filter(Boolean),
29
- // routes: (config as any).serverRoutes
30
- // }),
25
+ testingBffPlugin({
26
+ pwd: config.appDirectory,
27
+ userConfig,
28
+ plugins: config.plugins.map(p => p.server).filter(Boolean),
29
+ routes: (config as any).serverRoutes,
30
+ }),
31
31
  ];
32
32
 
33
33
  const runtimeExportsPath = path.join(
@@ -58,3 +58,13 @@ const test = async () => {
58
58
  };
59
59
 
60
60
  export default test;
61
+
62
+ declare module '@modern-js/core' {
63
+ interface UserConfig {
64
+ testing?: import('@modern-js/testing').TestConfig;
65
+ }
66
+
67
+ interface ToolsConfig {
68
+ jest?: import('@modern-js/testing').TestConfig['jest'];
69
+ }
70
+ }
@@ -1,4 +1,4 @@
1
1
  export { default as renderApp } from './customRender';
2
2
  export * from '@testing-library/react';
3
3
  export * from './reduck';
4
- // export { testBff } from '@modern-js/testing-plugin-bff';
4
+ export { testBff } from '@modern-js/testing-plugin-bff';
package/tsconfig.json CHANGED
@@ -8,5 +8,5 @@
8
8
  "@/*": ["./src/*"]
9
9
  }
10
10
  },
11
- "include": ["src", "./type.d.ts"]
11
+ "include": ["src"]
12
12
  }
package/type.d.ts CHANGED
@@ -1,5 +1,3 @@
1
- import { TestConfig } from '@modern-js/testing';
2
-
3
1
  declare module '@modern-js/runtime/testing' {
4
2
  export * from '@testing-library/react';
5
3
  export { renderApp, createStore } from '@modern-js/plugin-testing';
@@ -7,10 +5,10 @@ declare module '@modern-js/runtime/testing' {
7
5
 
8
6
  declare module '@modern-js/core' {
9
7
  interface UserConfig {
10
- testing?: TestConfig;
8
+ testing?: import('@modern-js/testing').TestConfig;
11
9
  }
12
10
 
13
11
  interface ToolsConfig {
14
- jest?: TestConfig['jest'];
12
+ jest?: import('@modern-js/testing').TestConfig['jest'];
15
13
  }
16
14
  }