@modern-js/plugin-testing 2.41.0 → 2.42.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. package/dist/cjs/base/runJest.js +4 -0
  2. package/dist/cjs/cli/index.js +1 -1
  3. package/dist/esm/base/runJest.js +4 -0
  4. package/dist/esm/cli/index.js +1 -1
  5. package/dist/esm-node/base/runJest.js +4 -0
  6. package/dist/esm-node/cli/index.js +1 -1
  7. package/dist/types/base/config/index.d.ts +8 -8
  8. package/dist/types/base/config/patches/assetsModule.d.ts +1 -1
  9. package/dist/types/base/config/patches/filemock.d.ts +1 -1
  10. package/dist/types/base/config/patches/index.d.ts +1 -1
  11. package/dist/types/base/config/patches/transformer.d.ts +1 -1
  12. package/dist/types/base/config/resolver.d.ts +1 -1
  13. package/dist/types/base/config/testConfigOperator.d.ts +15 -15
  14. package/dist/types/base/config/transformer/babelTransformer.d.ts +1 -1
  15. package/dist/types/base/hook.d.ts +5 -5
  16. package/dist/types/base/index.d.ts +1 -1
  17. package/dist/types/base/runJest.d.ts +4 -4
  18. package/dist/types/base/types/index.d.ts +1 -1
  19. package/dist/types/base/utils.d.ts +3 -3
  20. package/dist/types/cli/bff/app.d.ts +1 -1
  21. package/dist/types/cli/bff/constant.d.ts +1 -1
  22. package/dist/types/cli/bff/index.d.ts +10 -16
  23. package/dist/types/cli/bff/mockAPI.d.ts +1 -1
  24. package/dist/types/cli/bff/setup.d.ts +1 -1
  25. package/dist/types/cli/bff/utils/index.d.ts +1 -1
  26. package/dist/types/cli/index.d.ts +4 -4
  27. package/dist/types/cli/test.d.ts +4 -4
  28. package/dist/types/constant.d.ts +1 -1
  29. package/dist/types/index.d.ts +1 -1
  30. package/dist/types/runtime-testing/app.d.ts +17 -17
  31. package/dist/types/runtime-testing/base.d.ts +1 -1
  32. package/dist/types/runtime-testing/bff.d.ts +1 -1
  33. package/dist/types/runtime-testing/customRender.d.ts +1 -1
  34. package/dist/types/runtime-testing/index.d.ts +1 -1
  35. package/dist/types/runtime-testing/reduck.d.ts +1 -1
  36. package/dist/types/runtime-testing/resolvePlugins.d.ts +4 -4
  37. package/package.json +12 -12
@@ -52,6 +52,10 @@ const buildArgv = async (rawArgv, config) => {
52
52
  if (config) {
53
53
  result.config = JSON.stringify(config);
54
54
  }
55
+ if (result.u === true) {
56
+ result.updateSnapshot = true;
57
+ delete result.u;
58
+ }
55
59
  return result;
56
60
  };
57
61
  const readResultsAndExit = (result, globalConfig) => {
@@ -77,7 +77,7 @@ const testingPlugin = () => {
77
77
  let testingExportsUtils;
78
78
  return {
79
79
  commands: ({ program }) => {
80
- program.command("test").allowUnknownOption().usage("<regexForTestFiles> --[options]").action(async () => {
80
+ program.command("test").option("-u --updateSnapshot", "use this flag to re-record snapshots").option("--watch", "watch files for changes and rerun tests related to changed files").allowUnknownOption().usage("<regexForTestFiles> --[options]").action(async () => {
81
81
  await (0, import_test.default)(api);
82
82
  });
83
83
  },
@@ -30,6 +30,10 @@ var buildArgv = function() {
30
30
  if (config) {
31
31
  result.config = JSON.stringify(config);
32
32
  }
33
+ if (result.u === true) {
34
+ result.updateSnapshot = true;
35
+ delete result.u;
36
+ }
33
37
  return [
34
38
  2,
35
39
  result
@@ -45,7 +45,7 @@ var testingPlugin = function() {
45
45
  return {
46
46
  commands: function(param) {
47
47
  var program = param.program;
48
- program.command("test").allowUnknownOption().usage("<regexForTestFiles> --[options]").action(/* @__PURE__ */ _async_to_generator(function() {
48
+ program.command("test").option("-u --updateSnapshot", "use this flag to re-record snapshots").option("--watch", "watch files for changes and rerun tests related to changed files").allowUnknownOption().usage("<regexForTestFiles> --[options]").action(/* @__PURE__ */ _async_to_generator(function() {
49
49
  return _ts_generator(this, function(_state) {
50
50
  switch (_state.label) {
51
51
  case 0:
@@ -18,6 +18,10 @@ const buildArgv = async (rawArgv, config) => {
18
18
  if (config) {
19
19
  result.config = JSON.stringify(config);
20
20
  }
21
+ if (result.u === true) {
22
+ result.updateSnapshot = true;
23
+ delete result.u;
24
+ }
21
25
  return result;
22
26
  };
23
27
  const readResultsAndExit = (result, globalConfig) => {
@@ -41,7 +41,7 @@ const testingPlugin = () => {
41
41
  let testingExportsUtils;
42
42
  return {
43
43
  commands: ({ program }) => {
44
- program.command("test").allowUnknownOption().usage("<regexForTestFiles> --[options]").action(async () => {
44
+ program.command("test").option("-u --updateSnapshot", "use this flag to re-record snapshots").option("--watch", "watch files for changes and rerun tests related to changed files").allowUnknownOption().usage("<regexForTestFiles> --[options]").action(async () => {
45
45
  await test(api);
46
46
  });
47
47
  },
@@ -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": "2.41.0",
18
+ "version": "2.42.0",
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,16 +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/babel-compiler": "2.41.0",
135
- "@modern-js/utils": "2.41.0",
136
- "@modern-js/plugin": "2.41.0",
137
- "@modern-js/types": "2.41.0",
138
- "@modern-js/prod-server": "2.41.0"
134
+ "@modern-js/babel-compiler": "2.42.0",
135
+ "@modern-js/utils": "2.42.0",
136
+ "@modern-js/prod-server": "2.42.0",
137
+ "@modern-js/plugin": "2.42.0",
138
+ "@modern-js/types": "2.42.0",
139
+ "@modern-js/bff-core": "2.42.0"
139
140
  },
140
141
  "peerDependencies": {
141
142
  "react": ">=17",
142
143
  "react-dom": ">=17",
143
- "@modern-js/runtime": "^2.41.0"
144
+ "@modern-js/runtime": "^2.42.0"
144
145
  },
145
146
  "peerDependenciesMeta": {
146
147
  "@modern-js/runtime": {
@@ -155,11 +156,10 @@
155
156
  "@types/node": "^14",
156
157
  "@types/yargs": "^17.0.2",
157
158
  "typescript": "^5",
158
- "@modern-js/core": "2.41.0",
159
- "@modern-js/runtime": "2.41.0",
160
- "@modern-js/bff-core": "2.41.0",
161
- "@scripts/build": "2.41.0",
162
- "@scripts/jest-config": "2.41.0"
159
+ "@modern-js/core": "2.42.0",
160
+ "@modern-js/runtime": "2.42.0",
161
+ "@scripts/build": "2.42.0",
162
+ "@scripts/jest-config": "2.42.0"
163
163
  },
164
164
  "sideEffects": false,
165
165
  "publishConfig": {