@modern-js/plugin-testing 1.5.7 → 1.7.1-beta.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.
Files changed (100) hide show
  1. package/CHANGELOG.md +40 -0
  2. package/dist/js/modern/base/config/index.js +18 -0
  3. package/dist/js/modern/base/config/patches/assetsModule.js +11 -0
  4. package/dist/js/modern/base/config/patches/filemock.js +1 -0
  5. package/dist/js/modern/base/config/patches/index.js +13 -0
  6. package/dist/js/modern/base/config/patches/transformer.js +49 -0
  7. package/dist/js/modern/base/config/resolver.js +15 -0
  8. package/dist/js/modern/base/config/testConfigOperator.js +86 -0
  9. package/dist/js/modern/base/config/transformer/babelTransformer.js +12 -0
  10. package/dist/js/modern/base/hook.js +7 -0
  11. package/dist/js/modern/base/index.js +6 -0
  12. package/dist/js/modern/base/runJest.js +94 -0
  13. package/dist/js/modern/base/types/index.js +0 -0
  14. package/dist/js/modern/base/utils.js +59 -0
  15. package/dist/js/modern/cli/bff/app.js +43 -0
  16. package/dist/js/modern/cli/bff/constant.js +1 -0
  17. package/dist/js/modern/cli/bff/env.js +28 -0
  18. package/dist/js/modern/cli/bff/index.js +113 -0
  19. package/dist/js/modern/cli/bff/mockAPI.js +111 -0
  20. package/dist/js/modern/cli/bff/setup.js +44 -0
  21. package/dist/js/modern/cli/bff/utils/index.js +25 -0
  22. package/dist/js/modern/cli/index.js +2 -2
  23. package/dist/js/modern/cli/test.js +1 -1
  24. package/dist/js/modern/runtime-testing/app.js +1 -1
  25. package/dist/js/modern/runtime-testing/base.js +1 -1
  26. package/dist/js/modern/runtime-testing/request.js +17 -0
  27. package/dist/js/node/base/config/index.js +31 -0
  28. package/dist/js/node/base/config/patches/assetsModule.js +20 -0
  29. package/dist/js/node/base/config/patches/filemock.js +8 -0
  30. package/dist/js/node/base/config/patches/index.js +24 -0
  31. package/dist/js/node/base/config/patches/transformer.js +58 -0
  32. package/dist/js/node/base/config/resolver.js +20 -0
  33. package/dist/js/node/base/config/testConfigOperator.js +93 -0
  34. package/dist/js/node/base/config/transformer/babelTransformer.js +23 -0
  35. package/dist/js/node/base/hook.js +18 -0
  36. package/dist/js/node/base/index.js +73 -0
  37. package/dist/js/node/base/runJest.js +109 -0
  38. package/dist/js/node/base/types/index.js +0 -0
  39. package/dist/js/node/base/utils.js +79 -0
  40. package/dist/js/node/cli/bff/app.js +59 -0
  41. package/dist/js/node/cli/bff/constant.js +8 -0
  42. package/dist/js/node/cli/bff/env.js +42 -0
  43. package/dist/js/node/cli/bff/index.js +132 -0
  44. package/dist/js/node/cli/bff/mockAPI.js +126 -0
  45. package/dist/js/node/cli/bff/setup.js +53 -0
  46. package/dist/js/node/cli/bff/utils/index.js +38 -0
  47. package/dist/js/node/cli/index.js +7 -7
  48. package/dist/js/node/cli/test.js +2 -2
  49. package/dist/js/node/runtime-testing/app.js +2 -2
  50. package/dist/js/node/runtime-testing/base.js +2 -2
  51. package/dist/js/node/runtime-testing/request.js +24 -0
  52. package/dist/js/treeshaking/base/config/index.js +40 -0
  53. package/dist/js/treeshaking/base/config/patches/assetsModule.js +11 -0
  54. package/dist/js/treeshaking/base/config/patches/filemock.js +1 -0
  55. package/dist/js/treeshaking/base/config/patches/index.js +85 -0
  56. package/dist/js/treeshaking/base/config/patches/transformer.js +45 -0
  57. package/dist/js/treeshaking/base/config/resolver.js +17 -0
  58. package/dist/js/treeshaking/base/config/testConfigOperator.js +91 -0
  59. package/dist/js/treeshaking/base/config/transformer/babelTransformer.js +12 -0
  60. package/dist/js/treeshaking/base/hook.js +7 -0
  61. package/dist/js/treeshaking/base/index.js +6 -0
  62. package/dist/js/treeshaking/base/runJest.js +194 -0
  63. package/dist/js/treeshaking/base/types/index.js +0 -0
  64. package/dist/js/treeshaking/base/utils.js +60 -0
  65. package/dist/js/treeshaking/cli/bff/app.js +92 -0
  66. package/dist/js/treeshaking/cli/bff/constant.js +1 -0
  67. package/dist/js/treeshaking/cli/bff/env.js +98 -0
  68. package/dist/js/treeshaking/cli/bff/index.js +149 -0
  69. package/dist/js/treeshaking/cli/bff/mockAPI.js +115 -0
  70. package/dist/js/treeshaking/cli/bff/setup.js +76 -0
  71. package/dist/js/treeshaking/cli/bff/utils/index.js +22 -0
  72. package/dist/js/treeshaking/cli/index.js +2 -2
  73. package/dist/js/treeshaking/cli/test.js +1 -1
  74. package/dist/js/treeshaking/runtime-testing/app.js +1 -1
  75. package/dist/js/treeshaking/runtime-testing/base.js +1 -1
  76. package/dist/js/treeshaking/runtime-testing/request.js +24 -0
  77. package/dist/types/base/config/index.d.ts +124 -0
  78. package/dist/types/base/config/patches/assetsModule.d.ts +6 -0
  79. package/dist/types/base/config/patches/filemock.d.ts +3 -0
  80. package/dist/types/base/config/patches/index.d.ts +2 -0
  81. package/dist/types/base/config/patches/transformer.d.ts +6 -0
  82. package/dist/types/base/config/resolver.d.ts +1 -0
  83. package/dist/types/base/config/testConfigOperator.d.ts +248 -0
  84. package/dist/types/base/config/transformer/babelTransformer.d.ts +2 -0
  85. package/dist/types/base/hook.d.ts +13 -0
  86. package/dist/types/base/index.d.ts +6 -0
  87. package/dist/types/base/runJest.d.ts +22 -0
  88. package/dist/types/base/types/index.d.ts +1 -0
  89. package/dist/types/base/utils.d.ts +12 -0
  90. package/dist/types/cli/bff/app.d.ts +8 -0
  91. package/dist/types/cli/bff/constant.d.ts +1 -0
  92. package/dist/types/cli/bff/env.d.ts +6 -0
  93. package/dist/types/cli/bff/index.d.ts +19 -0
  94. package/dist/types/cli/bff/mockAPI.d.ts +3 -0
  95. package/dist/types/cli/bff/setup.d.ts +1 -0
  96. package/dist/types/cli/bff/utils/index.d.ts +1 -0
  97. package/dist/types/cli/index.d.ts +1 -1
  98. package/dist/types/runtime-testing/base.d.ts +1 -1
  99. package/dist/types/runtime-testing/request.d.ts +4 -0
  100. package/package.json +47 -11
@@ -0,0 +1,124 @@
1
+ import { TestConfig } from '../types';
2
+ import { TestConfigOperator } from './testConfigOperator';
3
+ /**
4
+ * Parse jest config
5
+ */
6
+
7
+ declare const getJestUtils: (testConfig: TestConfig) => TestConfigOperator;
8
+ declare const patchConfig: (testOperator: TestConfigOperator) => Promise<Partial<{
9
+ automock: boolean;
10
+ bail: number | boolean;
11
+ cache: boolean;
12
+ cacheDirectory: string;
13
+ ci: boolean;
14
+ clearMocks: boolean;
15
+ changedFilesWithAncestor: boolean;
16
+ changedSince: string;
17
+ collectCoverage: boolean;
18
+ collectCoverageFrom: string[];
19
+ collectCoverageOnlyFrom: {
20
+ [key: string]: boolean;
21
+ };
22
+ coverageDirectory: string;
23
+ coveragePathIgnorePatterns: string[];
24
+ coverageProvider: "babel" | "v8";
25
+ coverageReporters: import("@jest/types/build/Config").CoverageReporters;
26
+ coverageThreshold: {
27
+ [path: string]: import("@jest/types/build/Config").CoverageThresholdValue;
28
+ global: import("@jest/types/build/Config").CoverageThresholdValue;
29
+ };
30
+ dependencyExtractor: string;
31
+ detectLeaks: boolean;
32
+ detectOpenHandles: boolean;
33
+ displayName: string | import("@jest/types/build/Config").DisplayName;
34
+ expand: boolean;
35
+ extensionsToTreatAsEsm: string[];
36
+ extraGlobals: string[];
37
+ filter: string;
38
+ findRelatedTests: boolean;
39
+ forceCoverageMatch: string[];
40
+ forceExit: boolean;
41
+ json: boolean;
42
+ globals: import("@jest/types/build/Config").ConfigGlobals;
43
+ globalSetup: string | null | undefined;
44
+ globalTeardown: string | null | undefined;
45
+ haste: import("@jest/types/build/Config").HasteConfig;
46
+ injectGlobals: boolean;
47
+ reporters: (string | import("@jest/types/build/Config").ReporterConfig)[];
48
+ logHeapUsage: boolean;
49
+ lastCommit: boolean;
50
+ listTests: boolean;
51
+ maxConcurrency: number;
52
+ maxWorkers: string | number;
53
+ moduleDirectories: string[];
54
+ moduleFileExtensions: string[];
55
+ moduleLoader: string;
56
+ moduleNameMapper: {
57
+ [key: string]: string | string[];
58
+ };
59
+ modulePathIgnorePatterns: string[];
60
+ modulePaths: string[];
61
+ name: string;
62
+ noStackTrace: boolean;
63
+ notify: boolean;
64
+ notifyMode: string;
65
+ onlyChanged: boolean;
66
+ onlyFailures: boolean;
67
+ outputFile: string;
68
+ passWithNoTests: boolean;
69
+ preprocessorIgnorePatterns: string[];
70
+ preset: string | null | undefined;
71
+ prettierPath: string | null | undefined;
72
+ projects: (string | import("@jest/types/build/Config").InitialProjectOptions)[];
73
+ replname: string | null | undefined;
74
+ resetMocks: boolean;
75
+ resetModules: boolean;
76
+ resolver: string | null | undefined;
77
+ restoreMocks: boolean;
78
+ rootDir: string;
79
+ roots: string[];
80
+ runner: string;
81
+ runTestsByPath: boolean;
82
+ scriptPreprocessor: string;
83
+ setupFiles: string[];
84
+ setupTestFrameworkScriptFile: string;
85
+ setupFilesAfterEnv: string[];
86
+ silent: boolean;
87
+ skipFilter: boolean;
88
+ skipNodeResolution: boolean;
89
+ slowTestThreshold: number;
90
+ snapshotResolver: string;
91
+ snapshotSerializers: string[];
92
+ snapshotFormat: import("@jest/types/build/Config").PrettyFormatOptions;
93
+ errorOnDeprecated: boolean;
94
+ testEnvironment: string;
95
+ testEnvironmentOptions: Record<string, unknown>;
96
+ testFailureExitCode: string | number;
97
+ testLocationInResults: boolean;
98
+ testMatch: string[];
99
+ testNamePattern: string;
100
+ testPathDirs: string[];
101
+ testPathIgnorePatterns: string[];
102
+ testRegex: string | string[];
103
+ testResultsProcessor: string;
104
+ testRunner: string;
105
+ testSequencer: string;
106
+ testURL: string;
107
+ testTimeout: number;
108
+ timers: "modern" | "real" | "fake" | "legacy";
109
+ transform: {
110
+ [regex: string]: string | import("@jest/types/build/Config").TransformerConfig;
111
+ };
112
+ transformIgnorePatterns: string[];
113
+ watchPathIgnorePatterns: string[];
114
+ unmockedModulePathPatterns: string[];
115
+ updateSnapshot: boolean;
116
+ useStderr: boolean;
117
+ verbose?: boolean | undefined;
118
+ watch: boolean;
119
+ watchAll: boolean;
120
+ watchman: boolean;
121
+ watchPlugins: (string | [string, Record<string, unknown>])[];
122
+ }>>;
123
+ export declare const DEFAULT_RESOLVER_PATH: string;
124
+ export { getJestUtils, patchConfig };
@@ -0,0 +1,6 @@
1
+ import { TestConfigOperator } from '../testConfigOperator';
2
+ /**
3
+ * Merge config from testConfig.jest
4
+ */
5
+
6
+ export declare const patchAssetsModule: (testOperator: TestConfigOperator) => void;
@@ -0,0 +1,3 @@
1
+ declare const _default: "test-file-stub";
2
+
3
+ export default _default;
@@ -0,0 +1,2 @@
1
+ import { TestConfigOperator } from '../testConfigOperator';
2
+ export declare const applyPatches: (testConfig: TestConfigOperator) => Promise<void>;
@@ -0,0 +1,6 @@
1
+ import { TestConfigOperator } from '../testConfigOperator';
2
+ /**
3
+ * Map `TestConfig.transformer` to jest config
4
+ */
5
+
6
+ export declare const patchTransformer: (testOperator: TestConfigOperator) => void;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,248 @@
1
+ import { JestConfig, TestConfig } from '../types';
2
+
3
+ declare class TestConfigOperator {
4
+ private _testConfig;
5
+ private _jestConfig;
6
+ private readonly userJestConfig?;
7
+ private readonly defaultTestConfig;
8
+ constructor(testConfig: TestConfig);
9
+ 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
+ }>;
125
+ get testConfig(): TestConfig;
126
+ mergeJestConfig(sourceConfig: JestConfig): void;
127
+ setJestUserConfig(): void;
128
+ setJestConfig(sourceConfig: JestConfig, options?: {
129
+ force: boolean;
130
+ }): void;
131
+ getFinalConfig(): Partial<{
132
+ automock: boolean;
133
+ bail: number | boolean;
134
+ cache: boolean;
135
+ cacheDirectory: string;
136
+ ci: boolean;
137
+ clearMocks: boolean;
138
+ changedFilesWithAncestor: boolean;
139
+ changedSince: string;
140
+ collectCoverage: boolean;
141
+ collectCoverageFrom: string[];
142
+ collectCoverageOnlyFrom: {
143
+ [key: string]: boolean;
144
+ };
145
+ coverageDirectory: string;
146
+ coveragePathIgnorePatterns: string[];
147
+ coverageProvider: "babel" | "v8";
148
+ coverageReporters: import("@jest/types/build/Config").CoverageReporters;
149
+ coverageThreshold: {
150
+ [path: string]: import("@jest/types/build/Config").CoverageThresholdValue;
151
+ global: import("@jest/types/build/Config").CoverageThresholdValue;
152
+ };
153
+ dependencyExtractor: string;
154
+ detectLeaks: boolean;
155
+ detectOpenHandles: boolean;
156
+ displayName: string | import("@jest/types/build/Config").DisplayName;
157
+ expand: boolean;
158
+ extensionsToTreatAsEsm: string[];
159
+ extraGlobals: string[];
160
+ filter: string;
161
+ findRelatedTests: boolean;
162
+ forceCoverageMatch: string[];
163
+ forceExit: boolean;
164
+ json: boolean;
165
+ globals: import("@jest/types/build/Config").ConfigGlobals;
166
+ globalSetup: string | null | undefined;
167
+ globalTeardown: string | null | undefined;
168
+ haste: import("@jest/types/build/Config").HasteConfig;
169
+ injectGlobals: boolean;
170
+ reporters: (string | import("@jest/types/build/Config").ReporterConfig)[];
171
+ logHeapUsage: boolean;
172
+ lastCommit: boolean;
173
+ listTests: boolean;
174
+ maxConcurrency: number;
175
+ maxWorkers: string | number;
176
+ moduleDirectories: string[];
177
+ moduleFileExtensions: string[];
178
+ moduleLoader: string;
179
+ moduleNameMapper: {
180
+ [key: string]: string | string[];
181
+ };
182
+ modulePathIgnorePatterns: string[];
183
+ modulePaths: string[];
184
+ name: string;
185
+ noStackTrace: boolean;
186
+ notify: boolean;
187
+ notifyMode: string;
188
+ onlyChanged: boolean;
189
+ onlyFailures: boolean;
190
+ outputFile: string;
191
+ passWithNoTests: boolean;
192
+ preprocessorIgnorePatterns: string[];
193
+ preset: string | null | undefined;
194
+ prettierPath: string | null | undefined;
195
+ projects: (string | import("@jest/types/build/Config").InitialProjectOptions)[];
196
+ replname: string | null | undefined;
197
+ resetMocks: boolean;
198
+ resetModules: boolean;
199
+ resolver: string | null | undefined;
200
+ restoreMocks: boolean;
201
+ rootDir: string;
202
+ roots: string[];
203
+ runner: string;
204
+ runTestsByPath: boolean;
205
+ scriptPreprocessor: string;
206
+ setupFiles: string[];
207
+ setupTestFrameworkScriptFile: string;
208
+ setupFilesAfterEnv: string[];
209
+ silent: boolean;
210
+ skipFilter: boolean;
211
+ skipNodeResolution: boolean;
212
+ slowTestThreshold: number;
213
+ snapshotResolver: string;
214
+ snapshotSerializers: string[];
215
+ snapshotFormat: import("@jest/types/build/Config").PrettyFormatOptions;
216
+ errorOnDeprecated: boolean;
217
+ testEnvironment: string;
218
+ testEnvironmentOptions: Record<string, unknown>;
219
+ testFailureExitCode: string | number;
220
+ testLocationInResults: boolean;
221
+ testMatch: string[];
222
+ testNamePattern: string;
223
+ testPathDirs: string[];
224
+ testPathIgnorePatterns: string[];
225
+ testRegex: string | string[];
226
+ testResultsProcessor: string;
227
+ testRunner: string;
228
+ testSequencer: string;
229
+ testURL: string;
230
+ testTimeout: number;
231
+ timers: "modern" | "real" | "fake" | "legacy";
232
+ transform: {
233
+ [regex: string]: string | import("@jest/types/build/Config").TransformerConfig;
234
+ };
235
+ transformIgnorePatterns: string[];
236
+ watchPathIgnorePatterns: string[];
237
+ unmockedModulePathPatterns: string[];
238
+ updateSnapshot: boolean;
239
+ useStderr: boolean;
240
+ verbose?: boolean | undefined;
241
+ watch: boolean;
242
+ watchAll: boolean;
243
+ watchman: boolean;
244
+ watchPlugins: (string | [string, Record<string, unknown>])[];
245
+ }>;
246
+ }
247
+
248
+ export { TestConfigOperator };
@@ -0,0 +1,2 @@
1
+ declare const babelTransformer: any;
2
+ export default babelTransformer;
@@ -0,0 +1,13 @@
1
+ import { TestConfigOperator } from './config/testConfigOperator';
2
+ export declare const jestConfigHook: import("@modern-js/plugin").AsyncPipeline<TestConfigOperator, TestConfigOperator>;
3
+ export declare const afterTestHook: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
4
+ export declare const testingHooks: {
5
+ jestConfig: import("@modern-js/plugin").AsyncPipeline<TestConfigOperator, TestConfigOperator>;
6
+ afterTest: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
7
+ };
8
+ declare module '@modern-js/core' {
9
+ interface Hooks {
10
+ jestConfig: typeof jestConfigHook;
11
+ afterTest: typeof afterTestHook;
12
+ }
13
+ }
@@ -0,0 +1,6 @@
1
+ export { runTest, runJest } from './runJest';
2
+ export { getModuleNameMapper } from './utils';
3
+ export { DEFAULT_RESOLVER_PATH } from './config';
4
+ export { TestConfigOperator } from './config/testConfigOperator';
5
+ export { testingHooks } from './hook';
6
+ export * from './types';
@@ -0,0 +1,22 @@
1
+ /**
2
+ * @file run jest by nodejs API
3
+ * @description
4
+ * Jest does not provide node API to run jest.
5
+ * The followed code is inspired by
6
+ * https://github.com/facebook/jest/blob/fdc74af37235354e077edeeee8aa2d1a4a863032/packages/jest-cli/src/cli/index.ts#L21
7
+ */
8
+ import { Config } from '@jest/types';
9
+ import type { PluginAPI } from '@modern-js/core';
10
+ import { TestConfig } from './types';
11
+ declare type Argv = Omit<Config.Argv, '_' | '$0'>;
12
+ /**
13
+ * Node API: execute jest
14
+ */
15
+
16
+ export declare function runJest(config: Argv, pwd?: string): Promise<void>;
17
+ /**
18
+ * Node API: run test
19
+ */
20
+
21
+ export declare function runTest(api: PluginAPI, config: TestConfig, pwd?: string): Promise<void>;
22
+ export {};
@@ -0,0 +1 @@
1
+ export type { JestConfig, TestConfig } from '@modern-js/core';
@@ -0,0 +1,12 @@
1
+ export declare const debug: any;
2
+ interface TSConfig {
3
+ extends?: string;
4
+ compilerOptions?: Record<string, any>;
5
+ }
6
+ /**
7
+ * Read `compilerOptions` in the current pwd's tsconfig.json file
8
+ */
9
+
10
+ export declare const readCompilerOptions: (pwd?: string, filename?: string) => TSConfig['compilerOptions'];
11
+ export declare const getModuleNameMapper: (alias: any) => any;
12
+ export {};
@@ -0,0 +1,8 @@
1
+ /// <reference path="../../../../../../server/prod-server/src/type.d.ts" />
2
+ /// <reference types="node" />
3
+ /// <reference types="node/http" />
4
+ export declare const isInHandler: () => boolean;
5
+ declare const createApp: (pwd: string, config: any, plugins: any[], routes: any[]) => Promise<(req: import("http").IncomingMessage, res: import("http").ServerResponse, next?: (() => void) | undefined) => void>;
6
+ declare const getApp: () => (req: import("http").IncomingMessage, res: import("http").ServerResponse, next?: (() => void) | undefined) => void;
7
+ declare const closeServer: () => Promise<void>;
8
+ export { createApp, getApp, closeServer };
@@ -0,0 +1 @@
1
+ export declare const bff_info_key = "modern_bff_info";
@@ -0,0 +1,6 @@
1
+ import NodeEnvironment from 'jest-environment-node';
2
+ export default class extends NodeEnvironment {
3
+ app: any;
4
+ setup(): Promise<void>;
5
+ teardown(): Promise<void>;
6
+ }
@@ -0,0 +1,19 @@
1
+ import type { CliPlugin } from '@modern-js/core';
2
+ import { TestConfigOperator } from '../../base';
3
+ export declare const setJestConfigForBFF: ({
4
+ pwd,
5
+ userConfig,
6
+ plugins,
7
+ routes,
8
+ utils
9
+ }: {
10
+ pwd: string;
11
+ userConfig: any;
12
+ plugins: any[];
13
+ routes: any[];
14
+ utils: TestConfigOperator;
15
+ }) => Promise<void>;
16
+
17
+ declare const _default: () => CliPlugin;
18
+
19
+ export default _default;
@@ -0,0 +1,3 @@
1
+ declare const _default: (mockApiInfosByFile: Record<string, any[]>) => void;
2
+
3
+ export default _default;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare const isBFFProject: (pwd: string) => boolean;
@@ -1,5 +1,5 @@
1
1
  import type { CliPlugin } from '@modern-js/core';
2
- import { TestConfigOperator } from '@modern-js/testing';
2
+ import { TestConfigOperator } from '../base';
3
3
  export declare const mergeUserJestConfig: (testUtils: TestConfigOperator) => void;
4
4
 
5
5
  declare const _default: () => CliPlugin;
@@ -1,3 +1,3 @@
1
1
  export { default as renderApp } from './customRender';
2
2
  export * from '@testing-library/react';
3
- export { testBff } from '@modern-js/testing-plugin-bff';
3
+ export { request as testBff } from './request';
@@ -0,0 +1,4 @@
1
+ import type { SuperTest, Test } from 'supertest';
2
+ declare function request(): SuperTest<Test>;
3
+ declare function request<T extends (...argss: any[]) => any>(fn: T, ...args: Parameters<T>): Test;
4
+ export { request };
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.5.7",
14
+ "version": "1.7.1-beta.0",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -53,6 +53,14 @@
53
53
  "./cli": {
54
54
  "jsnext:source": "./src/cli/index.ts",
55
55
  "default": "./dist/js/node/cli/index.js"
56
+ },
57
+ "./bff-cli": {
58
+ "jsnext:source": "./src/cli/bff/index.ts",
59
+ "default": "./dist/js/node/cli/bff/index.js"
60
+ },
61
+ "./base": {
62
+ "jsnext:source": "./src/base/index.ts",
63
+ "default": "./dist/js/node/base/index.js"
56
64
  }
57
65
  },
58
66
  "typesVersions": {
@@ -74,6 +82,12 @@
74
82
  ],
75
83
  "runtime-base": [
76
84
  "./dist/types/runtime-testing/base.d.ts"
85
+ ],
86
+ "bff-cli": [
87
+ "./dist/types/cli/bff/index.d.ts"
88
+ ],
89
+ "base": [
90
+ "./dist/types/base/index.d.ts"
77
91
  ]
78
92
  }
79
93
  },
@@ -86,24 +100,45 @@
86
100
  "@modern-js-reduck/plugin-immutable": "^1.0.1",
87
101
  "@modern-js-reduck/store": "^1.0.3",
88
102
  "@modern-js/babel-compiler": "^1.2.6",
89
- "@modern-js/bff-utils": "^1.3.0",
90
- "@modern-js/runtime-core": "^1.5.2",
91
- "@modern-js/testing": "^1.5.4",
92
- "@modern-js/testing-plugin-bff": "^1.5.0",
93
- "@modern-js/utils": "^1.7.9",
94
- "@modern-js/webpack": "^1.11.3",
103
+ "@modern-js/utils": "^1.8.1",
104
+ "@modern-js/webpack": "^1.12.3",
105
+ "@modern-js/babel-preset-app": "^1.5.0",
106
+ "@modern-js/plugin": "^1.4.1",
107
+ "@modern-js/server": "^1.6.0",
95
108
  "@testing-library/jest-dom": "^5.14.1",
96
109
  "@testing-library/react": "^12.0.0",
97
- "@types/testing-library__jest-dom": "^5.14.3"
110
+ "@types/testing-library__jest-dom": "^5.14.3",
111
+ "jest-environment-node": "^27.2.2",
112
+ "path-to-regexp": "^6.2.0",
113
+ "supertest": "^6.1.6",
114
+ "babel-jest": "^27.0.6",
115
+ "enhanced-resolve": "^5.8.3",
116
+ "identity-obj-proxy": "^3.0.0",
117
+ "jest": "^27.0.6",
118
+ "ts-jest": "^27.0.4",
119
+ "yargs": "^17.0.1"
120
+ },
121
+ "peerDependencies": {
122
+ "@modern-js/runtime": "^1.4.1"
123
+ },
124
+ "peerDependenciesMeta": {
125
+ "@modern-js/runtime": {
126
+ "optional": true
127
+ }
98
128
  },
99
129
  "devDependencies": {
100
- "@modern-js/core": "1.12.2",
130
+ "@modern-js/core": "1.13.3",
131
+ "@modern-js/runtime": "1.4.4",
132
+ "@modern-js/bff-core": "1.2.1",
101
133
  "@scripts/build": "0.0.0",
102
134
  "@scripts/jest-config": "0.0.0",
103
135
  "@types/jest": "^27",
136
+ "@types/supertest": "^2.0.11",
104
137
  "@types/node": "^14",
105
138
  "@types/react": "^17",
106
139
  "@types/react-dom": "^17",
140
+ "@types/yargs": "^17.0.2",
141
+ "@jest/types": "^27.0.6",
107
142
  "jest": "^27",
108
143
  "react": "^17",
109
144
  "react-dom": "^17",
@@ -113,7 +148,8 @@
113
148
  "modernConfig": {},
114
149
  "publishConfig": {
115
150
  "registry": "https://registry.npmjs.org/",
116
- "access": "public"
151
+ "access": "public",
152
+ "types": "./dist/types/index.d.ts"
117
153
  },
118
154
  "wireit": {
119
155
  "build": {
@@ -128,7 +164,7 @@
128
164
  ]
129
165
  },
130
166
  "test": {
131
- "command": "jest --passWithNoTests",
167
+ "command": "jest",
132
168
  "files": [
133
169
  "src/**/*",
134
170
  "tsconfig.json",