@modern-js/plugin-testing 1.4.0 → 1.5.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 CHANGED
@@ -1,5 +1,66 @@
1
1
  # @modern-js/plugin-testing
2
2
 
3
+ ## 1.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 3bf4f8b0: feat: support start api server only
8
+
9
+ ### Patch Changes
10
+
11
+ - 04ae5262: chore: bump @modern-js/utils to v1.4.1 in dependencies
12
+ - 60f7d8bf: feat: add tests dir to npmignore
13
+ - Updated dependencies [b8599d09]
14
+ - Updated dependencies [6cffe99d]
15
+ - Updated dependencies [04ae5262]
16
+ - Updated dependencies [60f7d8bf]
17
+ - Updated dependencies [e4cec1ce]
18
+ - Updated dependencies [3bf4f8b0]
19
+ - @modern-js/utils@1.5.0
20
+ - @modern-js/webpack@1.5.5
21
+ - @modern-js/testing@1.4.3
22
+ - @modern-js/testing-plugin-bff@1.4.0
23
+ - @modern-js/runtime-core@1.4.2
24
+ - @modern-js/babel-compiler@1.2.3
25
+
26
+ ## 1.4.2
27
+
28
+ ### Patch Changes
29
+
30
+ - 77043407: feat: add default enhanced resolver
31
+ - Updated dependencies [485375ae]
32
+ - Updated dependencies [ec1b7367]
33
+ - Updated dependencies [77ff9754]
34
+ - Updated dependencies [d2d1d6b2]
35
+ - Updated dependencies [07a4887e]
36
+ - Updated dependencies [ea2ae711]
37
+ - Updated dependencies [77043407]
38
+ - Updated dependencies [17d0cc46]
39
+ - Updated dependencies [d2d1d6b2]
40
+ - @modern-js/runtime-core@1.4.1
41
+ - @modern-js/webpack@1.5.4
42
+ - @modern-js/utils@1.4.0
43
+ - @modern-js/testing@1.4.2
44
+ - @modern-js/testing-plugin-bff@1.3.1
45
+
46
+ ## 1.4.1
47
+
48
+ ### Patch Changes
49
+
50
+ - bebb39b6: chore: improve devDependencies and peerDependencies
51
+ - 132f7b53: feat: move config declarations to @modern-js/core
52
+ - 8491b6dd: fix: optimise "types" exports from plugin
53
+ - Updated dependencies [bebb39b6]
54
+ - Updated dependencies [4b4e73b7]
55
+ - Updated dependencies [da60172c]
56
+ - Updated dependencies [6cff93dc]
57
+ - Updated dependencies [132f7b53]
58
+ - Updated dependencies [9d4a005b]
59
+ - @modern-js/webpack@1.5.3
60
+ - @modern-js/testing@1.4.1
61
+ - @modern-js/utils@1.3.7
62
+ - @modern-js/testing-plugin-bff@1.3.0
63
+
3
64
  ## 1.4.0
4
65
 
5
66
  ### Minor Changes
@@ -1,6 +1,6 @@
1
1
  import path from 'path';
2
- import { fs, PLUGIN_SCHEMAS, createRuntimeExportsUtils } from '@modern-js/utils';
3
- import { jestConfigHook, getModuleNameMapper } from '@modern-js/testing';
2
+ import { PLUGIN_SCHEMAS, createRuntimeExportsUtils, isApiOnly } from '@modern-js/utils';
3
+ import { jestConfigHook, 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";
@@ -59,9 +59,9 @@ export default (() => {
59
59
  },
60
60
 
61
61
  jestConfig: async (utils, next) => {
62
- const existSrc = await fs.pathExists(appContext.srcDirectory);
62
+ const apiOnly = await isApiOnly(appContext.srcDirectory);
63
63
 
64
- if (!existSrc) {
64
+ if (apiOnly) {
65
65
  return next(utils);
66
66
  }
67
67
 
@@ -77,7 +77,7 @@ export default (() => {
77
77
  },
78
78
  moduleNameMapper: getModuleNameMapper(alias),
79
79
  testEnvironment: 'jsdom',
80
- resolver: require.resolve("./resolver")
80
+ resolver: DEFAULT_RESOLVER_PATH
81
81
  });
82
82
  utils.setJestConfig({
83
83
  rootDir: appContext.appDirectory || process.cwd(),
@@ -79,9 +79,9 @@ var _default = () => {
79
79
  },
80
80
 
81
81
  jestConfig: async (utils, next) => {
82
- const existSrc = await _utils.fs.pathExists(appContext.srcDirectory);
82
+ const apiOnly = await (0, _utils.isApiOnly)(appContext.srcDirectory);
83
83
 
84
- if (!existSrc) {
84
+ if (apiOnly) {
85
85
  return next(utils);
86
86
  }
87
87
 
@@ -97,7 +97,7 @@ var _default = () => {
97
97
  },
98
98
  moduleNameMapper: (0, _testing.getModuleNameMapper)(alias),
99
99
  testEnvironment: 'jsdom',
100
- resolver: require.resolve("./resolver")
100
+ resolver: _testing.DEFAULT_RESOLVER_PATH
101
101
  });
102
102
  utils.setJestConfig({
103
103
  rootDir: appContext.appDirectory || process.cwd(),
@@ -7,8 +7,8 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
7
7
  function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
8
8
 
9
9
  import path from 'path';
10
- import { fs, PLUGIN_SCHEMAS, createRuntimeExportsUtils } from '@modern-js/utils';
11
- import { jestConfigHook, getModuleNameMapper } from '@modern-js/testing';
10
+ import { PLUGIN_SCHEMAS, createRuntimeExportsUtils, isApiOnly } from '@modern-js/utils';
11
+ import { jestConfigHook, 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";
@@ -75,19 +75,19 @@ export default (function () {
75
75
  },
76
76
  jestConfig: function () {
77
77
  var _jestConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(utils, next) {
78
- var existSrc, webpackConfig, _webpackConfig$resolv, alias;
78
+ var apiOnly, webpackConfig, _webpackConfig$resolv, alias;
79
79
 
80
80
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
81
81
  while (1) {
82
82
  switch (_context2.prev = _context2.next) {
83
83
  case 0:
84
84
  _context2.next = 2;
85
- return fs.pathExists(appContext.srcDirectory);
85
+ return isApiOnly(appContext.srcDirectory);
86
86
 
87
87
  case 2:
88
- existSrc = _context2.sent;
88
+ apiOnly = _context2.sent;
89
89
 
90
- if (existSrc) {
90
+ if (!apiOnly) {
91
91
  _context2.next = 5;
92
92
  break;
93
93
  }
@@ -101,7 +101,7 @@ export default (function () {
101
101
  globals: _defineProperty({}, MODERNJS_CONFIG_KEY, userConfig),
102
102
  moduleNameMapper: getModuleNameMapper(alias),
103
103
  testEnvironment: 'jsdom',
104
- resolver: require.resolve("./resolver")
104
+ resolver: DEFAULT_RESOLVER_PATH
105
105
  });
106
106
  utils.setJestConfig({
107
107
  rootDir: appContext.appDirectory || process.cwd(),
@@ -1,11 +1,3 @@
1
1
  import type { PluginAPI } from '@modern-js/core';
2
2
  declare const test: (api: PluginAPI) => Promise<void>;
3
- export default test;
4
- declare module '@modern-js/core' {
5
- interface UserConfig {
6
- testing?: import('@modern-js/testing').TestConfig;
7
- }
8
- interface ToolsConfig {
9
- jest?: import('@modern-js/testing').TestConfig['jest'];
10
- }
11
- }
3
+ export default test;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { UserConfig } from '@modern-js/core';
2
+ import type { UserConfig } from '@modern-js/core';
3
3
  interface CreateAppProps {
4
4
  entry?: string;
5
5
  children?: React.ReactElement;
@@ -1,2 +1,2 @@
1
- import { NormalizedConfig } from '@modern-js/core';
1
+ import type { NormalizedConfig } from '@modern-js/core';
2
2
  export default function resolvePlugins(features: NormalizedConfig['runtime']): any[];
package/jest.config.js CHANGED
@@ -2,7 +2,6 @@ const sharedConfig = require('@scripts/jest-config');
2
2
 
3
3
  /** @type {import('@jest/types').Config.InitialOptions} */
4
4
  module.exports = {
5
- // eslint-disable-next-line node/no-unsupported-features/es-syntax
6
5
  ...sharedConfig,
7
6
  rootDir: __dirname,
8
7
  };
package/package.json CHANGED
@@ -11,13 +11,17 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.4.0",
14
+ "version": "1.5.0",
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
+ "./types": {
22
+ "jsnext:source": "./type.d.ts",
23
+ "default": "./type.d.ts"
24
+ },
21
25
  "./type": {
22
26
  "jsnext:source": "./type.d.ts",
23
27
  "default": "./type.d.ts"
@@ -68,6 +72,9 @@
68
72
  "type": [
69
73
  "./type.d.ts"
70
74
  ],
75
+ "types": [
76
+ "./type.d.ts"
77
+ ],
71
78
  "runtime-base": [
72
79
  "./dist/types/runtime-testing/base.d.ts"
73
80
  ]
@@ -76,22 +83,20 @@
76
83
  "dependencies": {
77
84
  "@babel/preset-env": "^7.15.6",
78
85
  "@babel/runtime": "^7",
79
- "@modern-js/babel-compiler": "^1.2.1",
80
- "@modern-js/testing": "^1.4.0",
81
- "@modern-js/utils": "^1.3.6",
82
- "@modern-js/webpack": "^1.5.0",
86
+ "@modern-js/babel-compiler": "^1.2.3",
87
+ "@modern-js/testing": "^1.4.3",
88
+ "@modern-js/utils": "^1.5.0",
89
+ "@modern-js/webpack": "^1.5.6",
83
90
  "@testing-library/jest-dom": "^5.14.1",
84
91
  "@testing-library/react": "^12.0.0",
85
- "enhanced-resolve": "^5.8.3",
86
- "@modern-js/testing-plugin-bff": "^1.3.0"
92
+ "@modern-js/testing-plugin-bff": "^1.4.0"
87
93
  },
88
94
  "peerDependencies": {
89
95
  "@modern-js-reduck/plugin-auto-actions": "^1.0.0",
90
96
  "@modern-js-reduck/plugin-effects": "^1.0.0",
91
97
  "@modern-js-reduck/plugin-immutable": "^1.0.0",
92
98
  "@modern-js-reduck/store": "^1.0.0",
93
- "@modern-js/core": "^1.6.0",
94
- "@modern-js/runtime-core": "^1.4.0"
99
+ "@modern-js/runtime-core": "^1.4.2"
95
100
  },
96
101
  "devDependencies": {
97
102
  "@modern-js-reduck/plugin-auto-actions": "^1.0.0",
@@ -99,8 +104,8 @@
99
104
  "@modern-js-reduck/plugin-immutable": "^1.0.0",
100
105
  "@modern-js-reduck/store": "^1.0.0",
101
106
  "@scripts/build": "0.0.0",
102
- "@modern-js/core": "^1.6.0",
103
- "@modern-js/runtime-core": "^1.4.0",
107
+ "@modern-js/core": "1.8.0",
108
+ "@modern-js/runtime-core": "1.4.2",
104
109
  "@types/jest": "^26",
105
110
  "@types/node": "^14",
106
111
  "@types/react": "^17",
package/type.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import '@modern-js/core';
2
1
  import "@testing-library/react"
3
2
  import "@testing-library/jest-dom"
4
3
  import "./dist/types/runtime-testing"
@@ -7,13 +6,3 @@ declare module '@modern-js/runtime/testing' {
7
6
  export * from '@testing-library/react';
8
7
  export { renderApp, createStore, testBff } from './dist/types/runtime-testing';
9
8
  }
10
-
11
- declare module '@modern-js/core' {
12
- interface UserConfig {
13
- testing?: import('@modern-js/testing').TestConfig;
14
- }
15
-
16
- interface ToolsConfig {
17
- jest?: import('@modern-js/testing').TestConfig['jest'];
18
- }
19
- }
@@ -1,15 +0,0 @@
1
- import enhanceResolve from 'enhanced-resolve';
2
- const resolver = enhanceResolve.create.sync({
3
- conditionNames: ['require', 'node', 'default'],
4
- extensions: ['.js', '.json', '.node', '.ts', '.tsx']
5
- });
6
-
7
- const shouldResolveByEnhance = url => /^@[^/]+\/[^/]+\/.*/.test(url);
8
-
9
- module.exports = function (request, options) {
10
- if (shouldResolveByEnhance(request)) {
11
- return resolver(options.basedir, request);
12
- }
13
-
14
- return options.defaultResolver(request, options);
15
- };
@@ -1,20 +0,0 @@
1
- "use strict";
2
-
3
- var _enhancedResolve = _interopRequireDefault(require("enhanced-resolve"));
4
-
5
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
6
-
7
- const resolver = _enhancedResolve.default.create.sync({
8
- conditionNames: ['require', 'node', 'default'],
9
- extensions: ['.js', '.json', '.node', '.ts', '.tsx']
10
- });
11
-
12
- const shouldResolveByEnhance = url => /^@[^/]+\/[^/]+\/.*/.test(url);
13
-
14
- module.exports = function (request, options) {
15
- if (shouldResolveByEnhance(request)) {
16
- return resolver(options.basedir, request);
17
- }
18
-
19
- return options.defaultResolver(request, options);
20
- };
@@ -1,17 +0,0 @@
1
- import enhanceResolve from 'enhanced-resolve';
2
- var resolver = enhanceResolve.create.sync({
3
- conditionNames: ['require', 'node', 'default'],
4
- extensions: ['.js', '.json', '.node', '.ts', '.tsx']
5
- });
6
-
7
- var shouldResolveByEnhance = function shouldResolveByEnhance(url) {
8
- return /^@[^/]+\/[^/]+\/.*/.test(url);
9
- };
10
-
11
- module.exports = function (request, options) {
12
- if (shouldResolveByEnhance(request)) {
13
- return resolver(options.basedir, request);
14
- }
15
-
16
- return options.defaultResolver(request, options);
17
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,6 +0,0 @@
1
- module.exports = {
2
- extends: ['@modern-js'],
3
- parserOptions: {
4
- project: require.resolve('./tsconfig.json'),
5
- },
6
- };
@@ -1,7 +0,0 @@
1
- import { createStore } from '../src';
2
-
3
- describe('plugin-testing', () => {
4
- it('default', () => {
5
- expect(createStore).toBeDefined();
6
- });
7
- });
@@ -1,54 +0,0 @@
1
- import { mergeUserJestConfig } from '../src/cli';
2
-
3
- describe('mergeUserJestConfig', () => {
4
- test('mergeUserJestConfig support object', () => {
5
- const testUtils: any = {
6
- _jestConfig: {
7
- a: 1,
8
- },
9
- get jestConfig() {
10
- return this._jestConfig;
11
- },
12
- testConfig: {
13
- jest: {
14
- b: 1,
15
- },
16
- },
17
- mergeJestConfig(config: Record<string, string>) {
18
- Object.assign(this._jestConfig, config);
19
- },
20
- };
21
-
22
- mergeUserJestConfig(testUtils);
23
-
24
- expect(testUtils.jestConfig).toEqual({
25
- a: 1,
26
- b: 1,
27
- });
28
- });
29
-
30
- test('mergeUserJestConfig support function', () => {
31
- const testUtils: any = {
32
- _jestConfig: {
33
- a: 1,
34
- },
35
- get jestConfig() {
36
- return this._jestConfig;
37
- },
38
- testConfig: {
39
- jest: (jestConfig: Record<string, number>) => {
40
- jestConfig.b = 1;
41
- },
42
- },
43
- mergeJestConfig(config: Record<string, string>) {
44
- Object.assign(this._jestConfig, config);
45
- },
46
- };
47
-
48
- mergeUserJestConfig(testUtils);
49
- expect(testUtils.jestConfig).toEqual({
50
- a: 1,
51
- b: 1,
52
- });
53
- });
54
- });
@@ -1,30 +0,0 @@
1
- import path from 'path';
2
- import { fs } from '@modern-js/utils';
3
-
4
- const resolver = require('../src/cli/resolver');
5
-
6
- describe('plugin-testing', () => {
7
- it('resolver', () => {
8
- const moduleDir = path.join(
9
- __dirname,
10
- 'node_modules/@modern-js/runtime/module',
11
- );
12
- fs.ensureDirSync(moduleDir);
13
- fs.writeJSONSync(
14
- path.join(moduleDir, 'package.json'),
15
- {
16
- name: '@modern-js/runtime/module',
17
- main: './index.js',
18
- },
19
- 'utf-8',
20
- );
21
- fs.writeFileSync(
22
- path.join(moduleDir, 'index.js'),
23
- 'module.exports = "@modern-js/runtime/module"',
24
- 'utf-8',
25
- );
26
- expect(
27
- resolver('@modern-js/runtime/module', { basedir: __dirname }),
28
- ).toContain('module');
29
- });
30
- });
@@ -1,13 +0,0 @@
1
- {
2
- "extends": "@modern-js/tsconfig/base",
3
- "compilerOptions": {
4
- "declaration": true,
5
- "jsx": "preserve",
6
- "baseUrl": "./",
7
- "outDir": "./out",
8
- "emitDeclarationOnly": true,
9
- "isolatedModules": true,
10
- "paths": {},
11
- "types": ["node", "jest"]
12
- }
13
- }