@modern-js/plugin-testing 0.0.0-nightly-20231206170639 → 0.0.0-nightly-20231207170637

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.
Files changed (34) hide show
  1. package/dist/cjs/base/config/transformer/babelTransformer.js +8 -1
  2. package/dist/esm/base/config/transformer/babelTransformer.js +8 -1
  3. package/dist/esm-node/base/config/transformer/babelTransformer.js +8 -1
  4. package/dist/types/base/config/index.d.ts +8 -8
  5. package/dist/types/base/config/patches/assetsModule.d.ts +1 -1
  6. package/dist/types/base/config/patches/filemock.d.ts +1 -1
  7. package/dist/types/base/config/patches/index.d.ts +1 -1
  8. package/dist/types/base/config/patches/transformer.d.ts +1 -1
  9. package/dist/types/base/config/resolver.d.ts +1 -1
  10. package/dist/types/base/config/testConfigOperator.d.ts +15 -15
  11. package/dist/types/base/config/transformer/babelTransformer.d.ts +1 -1
  12. package/dist/types/base/hook.d.ts +5 -5
  13. package/dist/types/base/index.d.ts +1 -1
  14. package/dist/types/base/runJest.d.ts +4 -4
  15. package/dist/types/base/types/index.d.ts +1 -1
  16. package/dist/types/base/utils.d.ts +3 -3
  17. package/dist/types/cli/bff/app.d.ts +1 -1
  18. package/dist/types/cli/bff/constant.d.ts +1 -1
  19. package/dist/types/cli/bff/index.d.ts +10 -16
  20. package/dist/types/cli/bff/mockAPI.d.ts +1 -1
  21. package/dist/types/cli/bff/setup.d.ts +1 -1
  22. package/dist/types/cli/bff/utils/index.d.ts +1 -1
  23. package/dist/types/cli/index.d.ts +4 -4
  24. package/dist/types/cli/test.d.ts +4 -4
  25. package/dist/types/constant.d.ts +1 -1
  26. package/dist/types/index.d.ts +1 -1
  27. package/dist/types/runtime-testing/app.d.ts +17 -17
  28. package/dist/types/runtime-testing/base.d.ts +1 -1
  29. package/dist/types/runtime-testing/bff.d.ts +1 -1
  30. package/dist/types/runtime-testing/customRender.d.ts +1 -1
  31. package/dist/types/runtime-testing/index.d.ts +1 -1
  32. package/dist/types/runtime-testing/reduck.d.ts +1 -1
  33. package/dist/types/runtime-testing/resolvePlugins.d.ts +4 -4
  34. package/package.json +12 -12
@@ -32,7 +32,9 @@ __export(babelTransformer_exports, {
32
32
  });
33
33
  module.exports = __toCommonJS(babelTransformer_exports);
34
34
  var import_babel_jest = __toESM(require("babel-jest"));
35
+ var import_utils = require("@modern-js/utils");
35
36
  var _babelJest_createTransformer;
37
+ const isNewJsx = (0, import_utils.isBeyondReact17)(process.cwd());
36
38
  const babelTransformer = (_babelJest_createTransformer = import_babel_jest.default.createTransformer) === null || _babelJest_createTransformer === void 0 ? void 0 : _babelJest_createTransformer.call(import_babel_jest.default, {
37
39
  presets: [
38
40
  [
@@ -43,7 +45,12 @@ const babelTransformer = (_babelJest_createTransformer = import_babel_jest.defau
43
45
  }
44
46
  }
45
47
  ],
46
- require.resolve("@babel/preset-react")
48
+ [
49
+ require.resolve("@babel/preset-react"),
50
+ {
51
+ runtime: isNewJsx ? "automatic" : "classic"
52
+ }
53
+ ]
47
54
  ],
48
55
  configFile: false,
49
56
  babelrc: false
@@ -1,5 +1,7 @@
1
1
  var _babelJest_createTransformer;
2
2
  import babelJest from "babel-jest";
3
+ import { isBeyondReact17 } from "@modern-js/utils";
4
+ var isNewJsx = isBeyondReact17(process.cwd());
3
5
  var babelTransformer = (_babelJest_createTransformer = babelJest.createTransformer) === null || _babelJest_createTransformer === void 0 ? void 0 : _babelJest_createTransformer.call(babelJest, {
4
6
  presets: [
5
7
  [
@@ -10,7 +12,12 @@ var babelTransformer = (_babelJest_createTransformer = babelJest.createTransform
10
12
  }
11
13
  }
12
14
  ],
13
- require.resolve("@babel/preset-react")
15
+ [
16
+ require.resolve("@babel/preset-react"),
17
+ {
18
+ runtime: isNewJsx ? "automatic" : "classic"
19
+ }
20
+ ]
14
21
  ],
15
22
  configFile: false,
16
23
  babelrc: false
@@ -1,5 +1,7 @@
1
1
  var _babelJest_createTransformer;
2
2
  import babelJest from "babel-jest";
3
+ import { isBeyondReact17 } from "@modern-js/utils";
4
+ const isNewJsx = isBeyondReact17(process.cwd());
3
5
  const babelTransformer = (_babelJest_createTransformer = babelJest.createTransformer) === null || _babelJest_createTransformer === void 0 ? void 0 : _babelJest_createTransformer.call(babelJest, {
4
6
  presets: [
5
7
  [
@@ -10,7 +12,12 @@ const babelTransformer = (_babelJest_createTransformer = babelJest.createTransfo
10
12
  }
11
13
  }
12
14
  ],
13
- require.resolve("@babel/preset-react")
15
+ [
16
+ require.resolve("@babel/preset-react"),
17
+ {
18
+ runtime: isNewJsx ? "automatic" : "classic"
19
+ }
20
+ ]
14
21
  ],
15
22
  configFile: false,
16
23
  babelrc: false
@@ -9,12 +9,12 @@ declare const getJestUtils: (testConfig: TestConfig) => TestConfigOperator;
9
9
  declare const patchConfig: (testOperator: TestConfigOperator) => Promise<JestConfigTypes.Config>;
10
10
  export declare const DEFAULT_RESOLVER_PATH: string;
11
11
  export type UserConfig = {
12
- source?: {
13
- alias?: AliasOption;
14
- };
15
- testing?: TestConfig;
16
- tools?: {
17
- jest: JestConfig | ((config: JestConfig) => JestConfig);
18
- };
12
+ source?: {
13
+ alias?: AliasOption;
14
+ };
15
+ testing?: TestConfig;
16
+ tools?: {
17
+ jest: JestConfig | ((config: JestConfig) => JestConfig);
18
+ };
19
19
  };
20
- export { getJestUtils, patchConfig };
20
+ export { getJestUtils, patchConfig };
@@ -2,4 +2,4 @@ import { TestConfigOperator } from '../testConfigOperator';
2
2
  /**
3
3
  * Merge config from testConfig.jest
4
4
  */
5
- export declare const patchAssetsModule: (testOperator: TestConfigOperator) => void;
5
+ export declare const patchAssetsModule: (testOperator: TestConfigOperator) => void;
@@ -1,2 +1,2 @@
1
1
  declare const _default: "test-file-stub";
2
- export default _default;
2
+ export default _default;
@@ -1,2 +1,2 @@
1
1
  import { TestConfigOperator } from '../testConfigOperator';
2
- export declare const applyPatches: (testConfig: TestConfigOperator) => Promise<void>;
2
+ export declare const applyPatches: (testConfig: TestConfigOperator) => Promise<void>;
@@ -2,4 +2,4 @@ import { TestConfigOperator } from '../testConfigOperator';
2
2
  /**
3
3
  * Map `TestConfig.transformer` to jest config
4
4
  */
5
- export declare const patchTransformer: (testOperator: TestConfigOperator) => void;
5
+ export declare const patchTransformer: (testOperator: TestConfigOperator) => void;
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1,18 +1,18 @@
1
1
  import type { JestConfig, TestConfig } from '@modern-js/types';
2
2
  declare class TestConfigOperator {
3
- private _testConfig;
4
- private _jestConfig;
5
- private readonly userJestConfig?;
6
- private readonly defaultTestConfig;
7
- constructor(testConfig: TestConfig);
8
- private initial;
9
- get jestConfig(): JestConfig;
10
- get testConfig(): TestConfig;
11
- mergeJestConfig(sourceConfig: JestConfig): void;
12
- setJestUserConfig(): void;
13
- setJestConfig(sourceConfig: JestConfig, options?: {
14
- force: boolean;
15
- }): void;
16
- getFinalConfig(): any;
3
+ private _testConfig;
4
+ private _jestConfig;
5
+ private readonly userJestConfig?;
6
+ private readonly defaultTestConfig;
7
+ constructor(testConfig: TestConfig);
8
+ private initial;
9
+ get jestConfig(): JestConfig;
10
+ get testConfig(): TestConfig;
11
+ mergeJestConfig(sourceConfig: JestConfig): void;
12
+ setJestUserConfig(): void;
13
+ setJestConfig(sourceConfig: JestConfig, options?: {
14
+ force: boolean;
15
+ }): void;
16
+ getFinalConfig(): any;
17
17
  }
18
- export { TestConfigOperator };
18
+ export { TestConfigOperator };
@@ -1,2 +1,2 @@
1
1
  declare const babelTransformer: any;
2
- export default babelTransformer;
2
+ export default babelTransformer;
@@ -2,10 +2,10 @@ import { TestConfigOperator } from './config/testConfigOperator';
2
2
  export declare const jestConfigHook: import("@modern-js/plugin").AsyncPipeline<TestConfigOperator, TestConfigOperator>;
3
3
  export declare const afterTestHook: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
4
4
  export declare const testingHooks: {
5
- jestConfig: import("@modern-js/plugin").AsyncPipeline<TestConfigOperator, TestConfigOperator>;
6
- afterTest: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
5
+ jestConfig: import("@modern-js/plugin").AsyncPipeline<TestConfigOperator, TestConfigOperator>;
6
+ afterTest: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
7
7
  };
8
8
  export type Hooks = {
9
- jestConfig: typeof jestConfigHook;
10
- afterTest: typeof afterTestHook;
11
- };
9
+ jestConfig: typeof jestConfigHook;
10
+ afterTest: typeof afterTestHook;
11
+ };
@@ -3,4 +3,4 @@ export { getModuleNameMapper } from './utils';
3
3
  export { DEFAULT_RESOLVER_PATH } from './config';
4
4
  export { TestConfigOperator } from './config/testConfigOperator';
5
5
  export { testingHooks } from './hook';
6
- export * from './types';
6
+ export * from './types';
@@ -19,8 +19,8 @@ export declare function runJest(config: Argv, pwd?: string): Promise<void>;
19
19
  * Node API: run test
20
20
  */
21
21
  export declare function runTest(api: PluginAPI<{
22
- hooks: Hooks;
23
- userConfig: UserConfig;
24
- normalizedConfig: Required<UserConfig>;
22
+ hooks: Hooks;
23
+ userConfig: UserConfig;
24
+ normalizedConfig: Required<UserConfig>;
25
25
  }>, config: TestConfig, pwd?: string): Promise<void>;
26
- export {};
26
+ export {};
@@ -1 +1 @@
1
- export type { JestConfig, TestConfig } from '@modern-js/types';
1
+ export type { JestConfig, TestConfig } from '@modern-js/types';
@@ -1,11 +1,11 @@
1
1
  export declare const debug: any;
2
2
  interface TSConfig {
3
- extends?: string;
4
- compilerOptions?: Record<string, any>;
3
+ extends?: string;
4
+ compilerOptions?: Record<string, any>;
5
5
  }
6
6
  /**
7
7
  * Read `compilerOptions` in the current pwd's tsconfig.json file
8
8
  */
9
9
  export declare const readCompilerOptions: (pwd?: string, filename?: string) => TSConfig['compilerOptions'];
10
10
  export declare const getModuleNameMapper: (alias: any) => any;
11
- export {};
11
+ export {};
@@ -6,4 +6,4 @@ export declare const isInHandler: () => boolean;
6
6
  declare const createApp: (pwd: string, config: any, plugins: InternalPlugins, routes: any[]) => Promise<(req: import("http").IncomingMessage, res: import("http").ServerResponse, next?: (() => void) | undefined) => void>;
7
7
  declare const getApp: () => (req: import("http").IncomingMessage, res: import("http").ServerResponse, next?: (() => void) | undefined) => void;
8
8
  declare const closeServer: () => Promise<void>;
9
- export { createApp, getApp, closeServer };
9
+ export { createApp, getApp, closeServer };
@@ -1 +1 @@
1
- export declare const bff_info_key = "modern_bff_info";
1
+ export declare const bff_info_key = "modern_bff_info";
@@ -3,21 +3,15 @@ import { InternalPlugins } from '@modern-js/types';
3
3
  import { UserConfig } from '../../base/config';
4
4
  import { TestConfigOperator } from '../../base';
5
5
  import type { Hooks } from '../../base/hook';
6
- export declare const setJestConfigForBFF: ({
7
- pwd,
8
- userConfig,
9
- plugins,
10
- routes,
11
- utils
12
- }: {
13
- pwd: string;
14
- userConfig: any;
15
- plugins: InternalPlugins;
16
- routes: any[];
17
- utils: TestConfigOperator;
6
+ export declare const setJestConfigForBFF: ({ pwd, userConfig, plugins, routes, utils, }: {
7
+ pwd: string;
8
+ userConfig: any;
9
+ plugins: InternalPlugins;
10
+ routes: any[];
11
+ utils: TestConfigOperator;
18
12
  }) => Promise<void>;
19
13
  export declare const testingBffPlugin: () => CliPlugin<{
20
- hooks: Hooks;
21
- userConfig: UserConfig;
22
- normalizedConfig: Required<UserConfig>;
23
- }>;
14
+ hooks: Hooks;
15
+ userConfig: UserConfig;
16
+ normalizedConfig: Required<UserConfig>;
17
+ }>;
@@ -1,2 +1,2 @@
1
1
  declare const _default: (mockApiInfosByFile: Record<string, any[]>) => void;
2
- export default _default;
2
+ export default _default;
@@ -1 +1 @@
1
- export {};
1
+ export {};
@@ -1 +1 @@
1
- export declare const isBFFProject: (pwd: string) => boolean;
1
+ export declare const isBFFProject: (pwd: string) => boolean;
@@ -5,8 +5,8 @@ import type { UserConfig } from '../base/config';
5
5
  export declare const mergeUserJestConfig: (testUtils: TestConfigOperator) => void;
6
6
  export declare const getJestTransformEsModulesRegStr: () => string;
7
7
  export declare const testingPlugin: () => CliPlugin<{
8
- hooks: Hooks;
9
- userConfig: UserConfig;
10
- normalizedConfig: Required<UserConfig>;
8
+ hooks: Hooks;
9
+ userConfig: UserConfig;
10
+ normalizedConfig: Required<UserConfig>;
11
11
  }>;
12
- export default testingPlugin;
12
+ export default testingPlugin;
@@ -2,8 +2,8 @@ import type { PluginAPI } from '@modern-js/core';
2
2
  import { Hooks } from '../base/hook';
3
3
  import { UserConfig } from '../base/config';
4
4
  declare const test: (api: PluginAPI<{
5
- hooks: Hooks;
6
- userConfig: UserConfig;
7
- normalizedConfig: Required<UserConfig>;
5
+ hooks: Hooks;
6
+ userConfig: UserConfig;
7
+ normalizedConfig: Required<UserConfig>;
8
8
  }>) => Promise<void>;
9
- export default test;
9
+ export default test;
@@ -1 +1 @@
1
- export declare const MODERNJS_CONFIG_KEY = "__modernjs_config__";
1
+ export declare const MODERNJS_CONFIG_KEY = "__modernjs_config__";
@@ -1,3 +1,3 @@
1
1
  import '@testing-library/jest-dom/extend-expect';
2
2
  import '@testing-library/jest-dom';
3
- export * from './runtime-testing';
3
+ export * from './runtime-testing';
@@ -1,24 +1,24 @@
1
1
  import React from 'react';
2
2
  import type { UserConfig } from '@modern-js/core';
3
3
  interface CreateAppProps {
4
- entry?: string;
5
- children?: React.ReactElement;
4
+ entry?: string;
5
+ children?: React.ReactElement;
6
6
  }
7
7
  declare class ModernRuntime {
8
- private options;
9
- constructor(options: UserConfig<{
10
- userConfig: {
11
- runtime?: any;
12
- runtimeByEntries?: any;
13
- };
14
- }>);
15
- init(options: UserConfig<{
16
- userConfig: {
17
- runtime?: any;
18
- runtimeByEntries?: any;
19
- };
20
- }>): void;
21
- createApp(props?: CreateAppProps): React.ComponentType<any>;
8
+ private options;
9
+ constructor(options: UserConfig<{
10
+ userConfig: {
11
+ runtime?: any;
12
+ runtimeByEntries?: any;
13
+ };
14
+ }>);
15
+ init(options: UserConfig<{
16
+ userConfig: {
17
+ runtime?: any;
18
+ runtimeByEntries?: any;
19
+ };
20
+ }>): void;
21
+ createApp(props?: CreateAppProps): React.ComponentType<any>;
22
22
  }
23
23
  declare const _default: ModernRuntime;
24
- export default _default;
24
+ export default _default;
@@ -1,2 +1,2 @@
1
1
  export { default as renderApp } from './customRender';
2
- export * from '@testing-library/react';
2
+ export * from '@testing-library/react';
@@ -1,4 +1,4 @@
1
1
  import type { SuperTest, Test } from 'supertest';
2
2
  declare function request(): SuperTest<Test>;
3
3
  declare function request<T extends (...argss: any[]) => any>(fn: T, ...args: Parameters<T>): Test;
4
- export { request as testBff };
4
+ export { request as testBff };
@@ -1,3 +1,3 @@
1
1
  import { render } from '@testing-library/react';
2
2
  declare const _default: typeof render;
3
- export default _default;
3
+ export default _default;
@@ -1,2 +1,2 @@
1
1
  export * from './base';
2
- export * from './reduck';
2
+ export * from './reduck';
@@ -2,4 +2,4 @@ import { createStore as originCreateStore } from '@modern-js-reduck/store';
2
2
  export declare const effects: () => (context: import("@modern-js-reduck/store/dist/types/types/plugin").PluginContext) => import("@modern-js-reduck/store/dist/types/types/plugin").PluginLifeCycle;
3
3
  export declare const immer: () => (context: import("@modern-js-reduck/store/dist/types/types/plugin").PluginContext) => import("@modern-js-reduck/store/dist/types/types/plugin").PluginLifeCycle;
4
4
  export declare const autoActions: () => (context: import("@modern-js-reduck/store/dist/types/types/plugin").PluginContext) => import("@modern-js-reduck/store/dist/types/types/plugin").PluginLifeCycle;
5
- export declare const createStore: typeof originCreateStore;
5
+ export declare const createStore: typeof originCreateStore;
@@ -1,6 +1,6 @@
1
1
  import type { NormalizedConfig } from '@modern-js/core';
2
2
  export default function resolvePlugins(features: NormalizedConfig<{
3
- normalizedConfig: {
4
- runtime: any;
5
- };
6
- }>['runtime']): any[];
3
+ normalizedConfig: {
4
+ runtime: any;
5
+ };
6
+ }>['runtime']): any[];
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "0.0.0-nightly-20231206170639",
18
+ "version": "0.0.0-nightly-20231207170637",
19
19
  "jsnext:source": "./src/cli/index.ts",
20
20
  "types": "./dist/types/cli/index.d.ts",
21
21
  "main": "./dist/cjs/cli/index.js",
@@ -131,17 +131,17 @@
131
131
  "ts-jest": "^29.1.0",
132
132
  "yargs": "^17.0.1",
133
133
  "@swc/helpers": "0.5.3",
134
- "@modern-js/utils": "0.0.0-nightly-20231206170639",
135
- "@modern-js/babel-compiler": "0.0.0-nightly-20231206170639",
136
- "@modern-js/prod-server": "0.0.0-nightly-20231206170639",
137
- "@modern-js/types": "0.0.0-nightly-20231206170639",
138
- "@modern-js/bff-core": "0.0.0-nightly-20231206170639",
139
- "@modern-js/plugin": "0.0.0-nightly-20231206170639"
134
+ "@modern-js/babel-compiler": "0.0.0-nightly-20231207170637",
135
+ "@modern-js/plugin": "0.0.0-nightly-20231207170637",
136
+ "@modern-js/utils": "0.0.0-nightly-20231207170637",
137
+ "@modern-js/prod-server": "0.0.0-nightly-20231207170637",
138
+ "@modern-js/types": "0.0.0-nightly-20231207170637",
139
+ "@modern-js/bff-core": "0.0.0-nightly-20231207170637"
140
140
  },
141
141
  "peerDependencies": {
142
142
  "react": ">=17",
143
143
  "react-dom": ">=17",
144
- "@modern-js/runtime": "0.0.0-nightly-20231206170639"
144
+ "@modern-js/runtime": "0.0.0-nightly-20231207170637"
145
145
  },
146
146
  "peerDependenciesMeta": {
147
147
  "@modern-js/runtime": {
@@ -156,10 +156,10 @@
156
156
  "@types/node": "^14",
157
157
  "@types/yargs": "^17.0.2",
158
158
  "typescript": "^5",
159
- "@modern-js/core": "0.0.0-nightly-20231206170639",
160
- "@modern-js/runtime": "0.0.0-nightly-20231206170639",
161
- "@scripts/build": "0.0.0-nightly-20231206170639",
162
- "@scripts/jest-config": "0.0.0-nightly-20231206170639"
159
+ "@modern-js/core": "0.0.0-nightly-20231207170637",
160
+ "@modern-js/runtime": "0.0.0-nightly-20231207170637",
161
+ "@scripts/build": "0.0.0-nightly-20231207170637",
162
+ "@scripts/jest-config": "0.0.0-nightly-20231207170637"
163
163
  },
164
164
  "sideEffects": false,
165
165
  "publishConfig": {