@modern-js/plugin-testing 2.0.0-beta.0 → 2.0.0-beta.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. package/CHANGELOG.md +109 -0
  2. package/dist/js/modern/base/config/index.js +1 -3
  3. package/dist/js/modern/base/config/patches/index.js +0 -2
  4. package/dist/js/modern/base/config/patches/transformer.js +1 -7
  5. package/dist/js/modern/base/config/resolver.js +0 -3
  6. package/dist/js/modern/base/config/testConfigOperator.js +0 -23
  7. package/dist/js/modern/base/config/transformer/babelTransformer.js +0 -1
  8. package/dist/js/modern/base/runJest.js +11 -14
  9. package/dist/js/modern/base/utils.js +2 -12
  10. package/dist/js/modern/cli/bff/app.js +0 -7
  11. package/dist/js/modern/cli/bff/index.js +4 -15
  12. package/dist/js/modern/cli/bff/mockAPI.js +4 -20
  13. package/dist/js/modern/cli/bff/setup.js +0 -5
  14. package/dist/js/modern/cli/bff/utils/index.js +0 -4
  15. package/dist/js/modern/cli/index.js +2 -9
  16. package/dist/js/modern/cli/test.js +0 -4
  17. package/dist/js/modern/runtime-testing/app.js +0 -15
  18. package/dist/js/modern/runtime-testing/customRender.js +0 -6
  19. package/dist/js/modern/runtime-testing/reduck.js +0 -10
  20. package/dist/js/modern/runtime-testing/request.js +1 -4
  21. package/dist/js/modern/runtime-testing/resolvePlugins.js +0 -6
  22. package/dist/js/node/base/config/index.js +0 -8
  23. package/dist/js/node/base/config/patches/assetsModule.js +0 -2
  24. package/dist/js/node/base/config/patches/index.js +0 -6
  25. package/dist/js/node/base/config/patches/transformer.js +1 -9
  26. package/dist/js/node/base/config/resolver.js +0 -5
  27. package/dist/js/node/base/config/testConfigOperator.js +0 -24
  28. package/dist/js/node/base/config/transformer/babelTransformer.js +0 -4
  29. package/dist/js/node/base/hook.js +0 -2
  30. package/dist/js/node/base/index.js +0 -7
  31. package/dist/js/node/base/runJest.js +11 -21
  32. package/dist/js/node/base/utils.js +2 -22
  33. package/dist/js/node/cli/bff/app.js +0 -14
  34. package/dist/js/node/cli/bff/index.js +4 -25
  35. package/dist/js/node/cli/bff/mockAPI.js +2 -25
  36. package/dist/js/node/cli/bff/setup.js +0 -11
  37. package/dist/js/node/cli/bff/utils/index.js +0 -9
  38. package/dist/js/node/cli/index.js +2 -21
  39. package/dist/js/node/cli/test.js +0 -10
  40. package/dist/js/node/index.js +0 -4
  41. package/dist/js/node/runtime-testing/app.js +0 -20
  42. package/dist/js/node/runtime-testing/base.js +0 -5
  43. package/dist/js/node/runtime-testing/customRender.js +0 -10
  44. package/dist/js/node/runtime-testing/index.js +0 -4
  45. package/dist/js/node/runtime-testing/reduck.js +0 -24
  46. package/dist/js/node/runtime-testing/request.js +1 -6
  47. package/dist/js/node/runtime-testing/resolvePlugins.js +0 -8
  48. package/dist/js/treeshaking/base/config/index.js +1 -6
  49. package/dist/js/treeshaking/base/config/patches/index.js +0 -17
  50. package/dist/js/treeshaking/base/config/patches/transformer.js +1 -7
  51. package/dist/js/treeshaking/base/config/resolver.js +0 -3
  52. package/dist/js/treeshaking/base/config/testConfigOperator.js +0 -15
  53. package/dist/js/treeshaking/base/config/transformer/babelTransformer.js +0 -1
  54. package/dist/js/treeshaking/base/runJest.js +19 -38
  55. package/dist/js/treeshaking/base/utils.js +2 -10
  56. package/dist/js/treeshaking/cli/bff/app.js +0 -13
  57. package/dist/js/treeshaking/cli/bff/index.js +0 -16
  58. package/dist/js/treeshaking/cli/bff/mockAPI.js +8 -24
  59. package/dist/js/treeshaking/cli/bff/setup.js +0 -9
  60. package/dist/js/treeshaking/cli/bff/utils/index.js +1 -2
  61. package/dist/js/treeshaking/cli/index.js +2 -11
  62. package/dist/js/treeshaking/cli/test.js +0 -7
  63. package/dist/js/treeshaking/runtime-testing/app.js +2 -15
  64. package/dist/js/treeshaking/runtime-testing/customRender.js +0 -3
  65. package/dist/js/treeshaking/runtime-testing/reduck.js +0 -7
  66. package/dist/js/treeshaking/runtime-testing/request.js +2 -7
  67. package/dist/js/treeshaking/runtime-testing/resolvePlugins.js +0 -3
  68. package/dist/types/base/config/index.d.ts +10 -1
  69. package/dist/types/base/config/patches/assetsModule.d.ts +0 -1
  70. package/dist/types/base/config/patches/filemock.d.ts +0 -1
  71. package/dist/types/base/config/patches/transformer.d.ts +0 -1
  72. package/dist/types/base/config/testConfigOperator.d.ts +1 -117
  73. package/dist/types/base/hook.d.ts +4 -6
  74. package/dist/types/base/runJest.d.ts +7 -3
  75. package/dist/types/base/utils.d.ts +0 -1
  76. package/dist/types/cli/bff/index.d.ts +7 -3
  77. package/dist/types/cli/bff/mockAPI.d.ts +0 -1
  78. package/dist/types/cli/index.d.ts +7 -3
  79. package/dist/types/cli/test.d.ts +7 -1
  80. package/dist/types/runtime-testing/app.d.ts +12 -5
  81. package/dist/types/runtime-testing/customRender.d.ts +0 -2
  82. package/dist/types/runtime-testing/resolvePlugins.d.ts +5 -1
  83. package/package.json +18 -18
@@ -1,5 +1,4 @@
1
1
  import { JestConfig, TestConfig } from '../types';
2
-
3
2
  declare class TestConfigOperator {
4
3
  private _testConfig;
5
4
  private _jestConfig;
@@ -7,121 +6,7 @@ declare class TestConfigOperator {
7
6
  private readonly defaultTestConfig;
8
7
  constructor(testConfig: TestConfig);
9
8
  private initial;
10
- get jestConfig(): Partial<{
11
- automock: boolean;
12
- bail: number | boolean;
13
- cache: boolean;
14
- cacheDirectory: string;
15
- ci: boolean;
16
- clearMocks: boolean;
17
- changedFilesWithAncestor: boolean;
18
- changedSince: string;
19
- collectCoverage: boolean;
20
- collectCoverageFrom: string[];
21
- collectCoverageOnlyFrom: {
22
- [key: string]: boolean;
23
- };
24
- coverageDirectory: string;
25
- coveragePathIgnorePatterns: string[];
26
- coverageProvider: "babel" | "v8";
27
- coverageReporters: import("@jest/types/build/Config").CoverageReporters;
28
- coverageThreshold: {
29
- [path: string]: import("@jest/types/build/Config").CoverageThresholdValue;
30
- global: import("@jest/types/build/Config").CoverageThresholdValue;
31
- };
32
- dependencyExtractor: string;
33
- detectLeaks: boolean;
34
- detectOpenHandles: boolean;
35
- displayName: string | import("@jest/types/build/Config").DisplayName;
36
- expand: boolean;
37
- extensionsToTreatAsEsm: string[];
38
- extraGlobals: string[];
39
- filter: string;
40
- findRelatedTests: boolean;
41
- forceCoverageMatch: string[];
42
- forceExit: boolean;
43
- json: boolean;
44
- globals: import("@jest/types/build/Config").ConfigGlobals;
45
- globalSetup: string | null | undefined;
46
- globalTeardown: string | null | undefined;
47
- haste: import("@jest/types/build/Config").HasteConfig;
48
- injectGlobals: boolean;
49
- reporters: (string | import("@jest/types/build/Config").ReporterConfig)[];
50
- logHeapUsage: boolean;
51
- lastCommit: boolean;
52
- listTests: boolean;
53
- maxConcurrency: number;
54
- maxWorkers: string | number;
55
- moduleDirectories: string[];
56
- moduleFileExtensions: string[];
57
- moduleLoader: string;
58
- moduleNameMapper: {
59
- [key: string]: string | string[];
60
- };
61
- modulePathIgnorePatterns: string[];
62
- modulePaths: string[];
63
- name: string;
64
- noStackTrace: boolean;
65
- notify: boolean;
66
- notifyMode: string;
67
- onlyChanged: boolean;
68
- onlyFailures: boolean;
69
- outputFile: string;
70
- passWithNoTests: boolean;
71
- preprocessorIgnorePatterns: string[];
72
- preset: string | null | undefined;
73
- prettierPath: string | null | undefined;
74
- projects: (string | import("@jest/types/build/Config").InitialProjectOptions)[];
75
- replname: string | null | undefined;
76
- resetMocks: boolean;
77
- resetModules: boolean;
78
- resolver: string | null | undefined;
79
- restoreMocks: boolean;
80
- rootDir: string;
81
- roots: string[];
82
- runner: string;
83
- runTestsByPath: boolean;
84
- scriptPreprocessor: string;
85
- setupFiles: string[];
86
- setupTestFrameworkScriptFile: string;
87
- setupFilesAfterEnv: string[];
88
- silent: boolean;
89
- skipFilter: boolean;
90
- skipNodeResolution: boolean;
91
- slowTestThreshold: number;
92
- snapshotResolver: string;
93
- snapshotSerializers: string[];
94
- snapshotFormat: import("@jest/types/build/Config").PrettyFormatOptions;
95
- errorOnDeprecated: boolean;
96
- testEnvironment: string;
97
- testEnvironmentOptions: Record<string, unknown>;
98
- testFailureExitCode: string | number;
99
- testLocationInResults: boolean;
100
- testMatch: string[];
101
- testNamePattern: string;
102
- testPathDirs: string[];
103
- testPathIgnorePatterns: string[];
104
- testRegex: string | string[];
105
- testResultsProcessor: string;
106
- testRunner: string;
107
- testSequencer: string;
108
- testURL: string;
109
- testTimeout: number;
110
- timers: "modern" | "real" | "fake" | "legacy";
111
- transform: {
112
- [regex: string]: string | import("@jest/types/build/Config").TransformerConfig;
113
- };
114
- transformIgnorePatterns: string[];
115
- watchPathIgnorePatterns: string[];
116
- unmockedModulePathPatterns: string[];
117
- updateSnapshot: boolean;
118
- useStderr: boolean;
119
- verbose?: boolean | undefined;
120
- watch: boolean;
121
- watchAll: boolean;
122
- watchman: boolean;
123
- watchPlugins: (string | [string, Record<string, unknown>])[];
124
- }>;
9
+ get jestConfig(): JestConfig;
125
10
  get testConfig(): TestConfig;
126
11
  mergeJestConfig(sourceConfig: JestConfig): void;
127
12
  setJestUserConfig(): void;
@@ -244,5 +129,4 @@ declare class TestConfigOperator {
244
129
  watchPlugins: (string | [string, Record<string, unknown>])[];
245
130
  }>;
246
131
  }
247
-
248
132
  export { TestConfigOperator };
@@ -5,9 +5,7 @@ export declare const testingHooks: {
5
5
  jestConfig: import("@modern-js/plugin").AsyncPipeline<TestConfigOperator, TestConfigOperator>;
6
6
  afterTest: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
7
7
  };
8
- declare module '@modern-js/core' {
9
- interface Hooks {
10
- jestConfig: typeof jestConfigHook;
11
- afterTest: typeof afterTestHook;
12
- }
13
- }
8
+ export declare type Hooks = {
9
+ jestConfig: typeof jestConfigHook;
10
+ afterTest: typeof afterTestHook;
11
+ };
@@ -7,16 +7,20 @@
7
7
  */
8
8
  import { Config } from '@jest/types';
9
9
  import type { PluginAPI } from '@modern-js/core';
10
+ import { UserConfig } from './config';
10
11
  import { TestConfig } from './types';
12
+ import type { Hooks } from './hook';
11
13
  declare type Argv = Omit<Config.Argv, '_' | '$0'>;
12
14
  /**
13
15
  * Node API: execute jest
14
16
  */
15
-
16
17
  export declare function runJest(config: Argv, pwd?: string): Promise<void>;
17
18
  /**
18
19
  * Node API: run test
19
20
  */
20
-
21
- export declare function runTest(api: PluginAPI, config: TestConfig, pwd?: string): Promise<void>;
21
+ export declare function runTest(api: PluginAPI<{
22
+ hooks: Hooks;
23
+ userConfig: UserConfig;
24
+ normalizedConfig: Required<UserConfig>;
25
+ }>, config: TestConfig, pwd?: string): Promise<void>;
22
26
  export {};
@@ -6,7 +6,6 @@ interface TSConfig {
6
6
  /**
7
7
  * Read `compilerOptions` in the current pwd's tsconfig.json file
8
8
  */
9
-
10
9
  export declare const readCompilerOptions: (pwd?: string, filename?: string) => TSConfig['compilerOptions'];
11
10
  export declare const getModuleNameMapper: (alias: any) => any;
12
11
  export {};
@@ -1,6 +1,8 @@
1
1
  import type { CliPlugin } from '@modern-js/core';
2
2
  import { InternalPlugins } from '@modern-js/types';
3
+ import { UserConfig } from '../../base/config';
3
4
  import { TestConfigOperator } from '../../base';
5
+ import type { Hooks } from '../../base/hook';
4
6
  export declare const setJestConfigForBFF: ({
5
7
  pwd,
6
8
  userConfig,
@@ -14,7 +16,9 @@ export declare const setJestConfigForBFF: ({
14
16
  routes: any[];
15
17
  utils: TestConfigOperator;
16
18
  }) => Promise<void>;
17
-
18
- declare const _default: () => CliPlugin;
19
-
19
+ declare const _default: () => CliPlugin<{
20
+ hooks: Hooks;
21
+ userConfig: UserConfig;
22
+ normalizedConfig: Required<UserConfig>;
23
+ }>;
20
24
  export default _default;
@@ -1,3 +1,2 @@
1
1
  declare const _default: (mockApiInfosByFile: Record<string, any[]>) => void;
2
-
3
2
  export default _default;
@@ -1,7 +1,11 @@
1
1
  import type { CliPlugin } from '@modern-js/core';
2
2
  import { TestConfigOperator } from '../base';
3
+ import type { Hooks } from '../base/hook';
4
+ import type { UserConfig } from '../base/config';
3
5
  export declare const mergeUserJestConfig: (testUtils: TestConfigOperator) => void;
4
-
5
- declare const _default: () => CliPlugin;
6
-
6
+ declare const _default: () => CliPlugin<{
7
+ hooks: Hooks;
8
+ userConfig: UserConfig;
9
+ normalizedConfig: Required<UserConfig>;
10
+ }>;
7
11
  export default _default;
@@ -1,3 +1,9 @@
1
1
  import type { PluginAPI } from '@modern-js/core';
2
- declare const test: (api: PluginAPI) => Promise<void>;
2
+ import { Hooks } from '../base/hook';
3
+ import { UserConfig } from '../base/config';
4
+ declare const test: (api: PluginAPI<{
5
+ hooks: Hooks;
6
+ userConfig: UserConfig;
7
+ normalizedConfig: Required<UserConfig>;
8
+ }>) => Promise<void>;
3
9
  export default test;
@@ -4,14 +4,21 @@ interface CreateAppProps {
4
4
  entry?: string;
5
5
  children?: React.ReactElement;
6
6
  }
7
-
8
7
  declare class ModernRuntime {
9
8
  private options;
10
- constructor(options: UserConfig);
11
- init(options: UserConfig): void;
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;
12
21
  createApp(props?: CreateAppProps): React.ComponentType<any>;
13
22
  }
14
-
15
23
  declare const _default: ModernRuntime;
16
-
17
24
  export default _default;
@@ -1,5 +1,3 @@
1
1
  import { render } from '@testing-library/react';
2
-
3
2
  declare const _default: typeof render;
4
-
5
3
  export default _default;
@@ -1,2 +1,6 @@
1
1
  import type { NormalizedConfig } from '@modern-js/core';
2
- export default function resolvePlugins(features: NormalizedConfig['runtime']): any[];
2
+ export default function resolvePlugins(features: NormalizedConfig<{
3
+ normalizedConfig: {
4
+ runtime: any;
5
+ };
6
+ }>['runtime']): any[];
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "2.0.0-beta.0",
14
+ "version": "2.0.0-beta.2",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -99,11 +99,6 @@
99
99
  "@modern-js-reduck/plugin-effects": "^1.0.2",
100
100
  "@modern-js-reduck/plugin-immutable": "^1.0.1",
101
101
  "@modern-js-reduck/store": "^1.0.3",
102
- "@modern-js/babel-compiler": "2.0.0-beta.0",
103
- "@modern-js/utils": "2.0.0-beta.0",
104
- "@modern-js/babel-preset-app": "2.0.0-beta.0",
105
- "@modern-js/plugin": "2.0.0-beta.0",
106
- "@modern-js/prod-server": "2.0.0-beta.0",
107
102
  "@testing-library/jest-dom": "^5.14.1",
108
103
  "@testing-library/react": "^13.4.0",
109
104
  "@types/testing-library__jest-dom": "^5.14.3",
@@ -115,12 +110,17 @@
115
110
  "identity-obj-proxy": "^3.0.0",
116
111
  "jest": "^27.0.6",
117
112
  "ts-jest": "^27.0.4",
118
- "yargs": "^17.0.1"
113
+ "yargs": "^17.0.1",
114
+ "@modern-js/babel-compiler": "2.0.0-beta.2",
115
+ "@modern-js/utils": "2.0.0-beta.2",
116
+ "@modern-js/babel-preset-app": "2.0.0-beta.2",
117
+ "@modern-js/plugin": "2.0.0-beta.2",
118
+ "@modern-js/prod-server": "2.0.0-beta.2"
119
119
  },
120
120
  "peerDependencies": {
121
121
  "react": ">=17",
122
122
  "react-dom": ">=17",
123
- "@modern-js/runtime": "^2.0.0-beta.0"
123
+ "@modern-js/runtime": "^2.0.0-beta.2"
124
124
  },
125
125
  "peerDependenciesMeta": {
126
126
  "@modern-js/runtime": {
@@ -130,19 +130,19 @@
130
130
  "devDependencies": {
131
131
  "react": "^18",
132
132
  "react-dom": "^18",
133
- "@modern-js/core": "2.0.0-beta.0",
134
- "@modern-js/types": "2.0.0-beta.0",
135
- "@modern-js/runtime": "2.0.0-beta.0",
136
- "@modern-js/bff-core": "2.0.0-beta.0",
137
- "@scripts/build": "2.0.0-beta.0",
138
- "@scripts/jest-config": "2.0.0-beta.0",
139
133
  "@types/jest": "^27",
140
134
  "@types/supertest": "^2.0.11",
141
135
  "@types/node": "^14",
142
136
  "@types/yargs": "^17.0.2",
143
137
  "@jest/types": "^27.0.6",
144
138
  "jest": "^27",
145
- "typescript": "^4"
139
+ "typescript": "^4",
140
+ "@modern-js/core": "2.0.0-beta.2",
141
+ "@modern-js/types": "2.0.0-beta.2",
142
+ "@modern-js/runtime": "2.0.0-beta.2",
143
+ "@modern-js/bff-core": "2.0.0-beta.2",
144
+ "@scripts/build": "2.0.0-beta.2",
145
+ "@scripts/jest-config": "2.0.0-beta.2"
146
146
  },
147
147
  "sideEffects": false,
148
148
  "modernConfig": {},
@@ -151,9 +151,9 @@
151
151
  "access": "public"
152
152
  },
153
153
  "scripts": {
154
- "new": "modern new",
155
- "dev": "modern build --watch",
156
- "build": "modern build",
154
+ "new": "modern-lib new",
155
+ "dev": "modern-lib build --watch",
156
+ "build": "modern-lib build",
157
157
  "test": "jest"
158
158
  }
159
159
  }