@rstest/core 0.6.0 → 0.6.2

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.
@@ -318,6 +318,7 @@ declare type CommonOptions = {
318
318
  coverage?: boolean;
319
319
  passWithNoTests?: boolean;
320
320
  printConsoleTrace?: boolean;
321
+ logHeapUsage?: boolean;
321
322
  disableConsoleIntercept?: boolean;
322
323
  update?: boolean;
323
324
  testNamePattern?: RegExp | string;
@@ -613,7 +614,7 @@ declare type DefaultReporterOptions = {
613
614
 
614
615
  /**
615
616
  * This function helps you to autocomplete configuration types.
616
- * It accepts a Rsbuild config object, or a function that returns a config.
617
+ * It accepts a Rstest config object, or a function that returns a config.
617
618
  */
618
619
  export declare function defineConfig(config: RstestConfig): RstestConfig;
619
620
 
@@ -623,6 +624,16 @@ export declare function defineConfig(config: RstestConfigAsyncFn): RstestConfigA
623
624
 
624
625
  export declare function defineConfig(config: RstestConfigExport): RstestConfigExport;
625
626
 
627
+ /**
628
+ * This function helps you to autocomplete configuration types.
629
+ * It accepts a Rstest project config object, or a function that returns a config.
630
+ */
631
+ export declare function defineProject(config: ProjectConfig): ProjectConfig;
632
+
633
+ export declare function defineProject(config: ProjectConfigSyncFn): ProjectConfigSyncFn;
634
+
635
+ export declare function defineProject(config: ProjectConfigAsyncFn): ProjectConfigAsyncFn;
636
+
626
637
  export declare const describe: Rstest['describe'];
627
638
 
628
639
  declare type DescribeAPI = DescribeFn & {
@@ -1996,7 +2007,11 @@ declare type Project = {
1996
2007
  configFilePath?: string;
1997
2008
  };
1998
2009
 
1999
- export declare type ProjectConfig = Omit<RstestConfig, 'projects' | 'reporters' | 'pool' | 'isolate' | 'coverage'>;
2010
+ export declare type ProjectConfig = Omit<RstestConfig, 'projects' | 'reporters' | 'pool' | 'isolate' | 'coverage' | 'resolveSnapshotPath' | 'onConsoleLog' | 'hideSkippedTests'>;
2011
+
2012
+ declare type ProjectConfigAsyncFn = () => Promise<ProjectConfig>;
2013
+
2014
+ declare type ProjectConfigSyncFn = () => ProjectConfig;
2000
2015
 
2001
2016
  declare type ProjectContext = {
2002
2017
  name: string;
@@ -2282,6 +2297,11 @@ export declare interface RstestConfig {
2282
2297
  * @default 5
2283
2298
  */
2284
2299
  maxConcurrency?: number;
2300
+ /**
2301
+ * Log heap usage after each test
2302
+ * @default false
2303
+ */
2304
+ logHeapUsage?: boolean;
2285
2305
  /**
2286
2306
  * Custom handler for console log in tests
2287
2307
  */
@@ -2503,7 +2523,7 @@ declare type RunnerAPI = {
2503
2523
  onTestFailed: (fn: OnTestFailedHandler, timeout?: number) => void;
2504
2524
  };
2505
2525
 
2506
- declare type RuntimeConfig = Pick<RstestContext['normalizedConfig'], 'testTimeout' | 'testNamePattern' | 'globals' | 'passWithNoTests' | 'retry' | 'clearMocks' | 'resetMocks' | 'restoreMocks' | 'unstubEnvs' | 'unstubGlobals' | 'maxConcurrency' | 'printConsoleTrace' | 'disableConsoleIntercept' | 'testEnvironment' | 'isolate' | 'hookTimeout' | 'coverage' | 'snapshotFormat' | 'env'>;
2526
+ declare type RuntimeConfig = Pick<RstestContext['normalizedConfig'], 'testTimeout' | 'testNamePattern' | 'globals' | 'passWithNoTests' | 'retry' | 'clearMocks' | 'resetMocks' | 'restoreMocks' | 'unstubEnvs' | 'unstubGlobals' | 'maxConcurrency' | 'printConsoleTrace' | 'disableConsoleIntercept' | 'testEnvironment' | 'isolate' | 'hookTimeout' | 'coverage' | 'snapshotFormat' | 'env' | 'logHeapUsage'>;
2507
2527
 
2508
2528
  declare type RuntimeOptions = Partial<Pick<RuntimeConfig, 'testTimeout' | 'hookTimeout' | 'clearMocks' | 'resetMocks' | 'restoreMocks' | 'maxConcurrency' | 'retry'>>;
2509
2529
 
@@ -2746,6 +2766,7 @@ declare type TestContext = {
2746
2766
  declare interface TestEachFn {
2747
2767
  <T extends Record<string, unknown>>(cases: readonly T[]): (description: string, fn?: (param: T) => MaybePromise<void>, timeout?: number) => void;
2748
2768
  <T extends readonly [unknown, ...unknown[]]>(cases: readonly T[]): (description: string, fn: (...args: [...T]) => MaybePromise<void>, timeout?: number) => void;
2769
+ <T>(cases: readonly T[]): (description: string, fn: (...args: T[]) => MaybePromise<void>, timeout?: number) => void;
2749
2770
  }
2750
2771
 
2751
2772
  declare type Tester = (this: TesterContext, a: any, b: any, customTesters: Array<Tester>) => boolean | undefined;
@@ -2787,6 +2808,7 @@ export declare type TestResult = {
2787
2808
  errors?: FormattedError[];
2788
2809
  retryCount?: number;
2789
2810
  project: string;
2811
+ heap?: number;
2790
2812
  };
2791
2813
 
2792
2814
  declare type TestResultStatus = 'skip' | 'pass' | 'fail' | 'todo';
@@ -1664,7 +1664,7 @@ declare function printWithType<T>(name: string, value: T, print: (value: T) => s
1664
1664
 
1665
1665
  declare type Procedure = (...args: any[]) => any;
1666
1666
 
1667
- declare type ProjectConfig = Omit<RstestConfig, 'projects' | 'reporters' | 'pool' | 'isolate' | 'coverage'>;
1667
+ declare type ProjectConfig = Omit<RstestConfig, 'projects' | 'reporters' | 'pool' | 'isolate' | 'coverage' | 'resolveSnapshotPath' | 'onConsoleLog' | 'hideSkippedTests'>;
1668
1668
 
1669
1669
  declare type ProjectContext = {
1670
1670
  name: string;
@@ -1937,6 +1937,11 @@ declare interface RstestConfig {
1937
1937
  * @default 5
1938
1938
  */
1939
1939
  maxConcurrency?: number;
1940
+ /**
1941
+ * Log heap usage after each test
1942
+ * @default false
1943
+ */
1944
+ logHeapUsage?: boolean;
1940
1945
  /**
1941
1946
  * Custom handler for console log in tests
1942
1947
  */
@@ -2026,7 +2031,7 @@ declare type RunnerAPI = {
2026
2031
  onTestFailed: (fn: OnTestFailedHandler, timeout?: number) => void;
2027
2032
  };
2028
2033
 
2029
- declare type RuntimeConfig = Pick<RstestContext['normalizedConfig'], 'testTimeout' | 'testNamePattern' | 'globals' | 'passWithNoTests' | 'retry' | 'clearMocks' | 'resetMocks' | 'restoreMocks' | 'unstubEnvs' | 'unstubGlobals' | 'maxConcurrency' | 'printConsoleTrace' | 'disableConsoleIntercept' | 'testEnvironment' | 'isolate' | 'hookTimeout' | 'coverage' | 'snapshotFormat' | 'env'>;
2034
+ declare type RuntimeConfig = Pick<RstestContext['normalizedConfig'], 'testTimeout' | 'testNamePattern' | 'globals' | 'passWithNoTests' | 'retry' | 'clearMocks' | 'resetMocks' | 'restoreMocks' | 'unstubEnvs' | 'unstubGlobals' | 'maxConcurrency' | 'printConsoleTrace' | 'disableConsoleIntercept' | 'testEnvironment' | 'isolate' | 'hookTimeout' | 'coverage' | 'snapshotFormat' | 'env' | 'logHeapUsage'>;
2030
2035
 
2031
2036
  /** Runtime to Server */
2032
2037
  declare type RuntimeRPC = {
@@ -2342,6 +2347,7 @@ declare type TestContext = {
2342
2347
  declare interface TestEachFn {
2343
2348
  <T extends Record<string, unknown>>(cases: readonly T[]): (description: string, fn?: (param: T) => MaybePromise<void>, timeout?: number) => void;
2344
2349
  <T extends readonly [unknown, ...unknown[]]>(cases: readonly T[]): (description: string, fn: (...args: [...T]) => MaybePromise<void>, timeout?: number) => void;
2350
+ <T>(cases: readonly T[]): (description: string, fn: (...args: T[]) => MaybePromise<void>, timeout?: number) => void;
2345
2351
  }
2346
2352
 
2347
2353
  declare type Tester = (this: TesterContext, a: any, b: any, customTesters: Array<Tester>) => boolean | undefined;
@@ -2383,6 +2389,7 @@ declare type TestResult = {
2383
2389
  errors?: FormattedError[];
2384
2390
  retryCount?: number;
2385
2391
  project: string;
2392
+ heap?: number;
2386
2393
  };
2387
2394
 
2388
2395
  declare type TestResultStatus = 'skip' | 'pass' | 'fail' | 'todo';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rstest/core",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "description": "The Rsbuild-based test tool.",
5
5
  "bugs": {
6
6
  "url": "https://github.com/web-infra-dev/rstest/issues"
@@ -59,8 +59,8 @@
59
59
  "@vitest/snapshot": "^3.2.4",
60
60
  "@babel/code-frame": "^7.27.1",
61
61
  "@jridgewell/trace-mapping": "0.3.31",
62
- "@microsoft/api-extractor": "^7.53.2",
63
- "@rslib/core": "0.16.0",
62
+ "@microsoft/api-extractor": "^7.53.3",
63
+ "@rslib/core": "0.17.0",
64
64
  "@sinonjs/fake-timers": "^14.0.0",
65
65
  "@types/babel__code-frame": "^7.0.6",
66
66
  "@types/istanbul-reports": "^3.0.4",
package/dist/0~33.js DELETED
@@ -1,425 +0,0 @@
1
- import 'module';
2
- /*#__PURE__*/ import.meta.url;
3
- export const __webpack_id__ = "33";
4
- export const __webpack_ids__ = [
5
- "33"
6
- ];
7
- export const __webpack_modules__ = {
8
- "./src/core/runTests.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
9
- __webpack_require__.d(__webpack_exports__, {
10
- runTests: ()=>runTests
11
- });
12
- var src_coverage = __webpack_require__("./src/coverage/index.ts");
13
- var src_pool = __webpack_require__("./src/pool/index.ts");
14
- var utils = __webpack_require__("./src/utils/index.ts");
15
- const isCliShortcutsEnabled = ()=>(0, utils.Un)('stdin');
16
- async function setupCliShortcuts({ closeServer, runAll, updateSnapshot, runFailedTests, runWithTestNamePattern, runWithFileFilters }) {
17
- const { createInterface, emitKeypressEvents } = await import("node:readline");
18
- const rl = createInterface({
19
- input: process.stdin,
20
- output: process.stdout
21
- });
22
- emitKeypressEvents(process.stdin);
23
- process.stdin.setRawMode(true);
24
- process.stdin.resume();
25
- process.stdin.setEncoding('utf8');
26
- let isPrompting = false;
27
- const clearCurrentInputLine = ()=>{
28
- try {
29
- process.stdout.write('\r\x1b[2K');
30
- } catch {}
31
- };
32
- const promptInput = async (promptText, onComplete)=>{
33
- if (isPrompting) return;
34
- isPrompting = true;
35
- let buffer = '';
36
- const render = ()=>{
37
- process.stdout.write(`\r\x1b[2K${promptText}${buffer}`);
38
- };
39
- render();
40
- const onPromptKey = async (str, key)=>{
41
- if (!isPrompting) return;
42
- if (key.ctrl && 'c' === key.name) process.exit(0);
43
- if ('return' === key.name || 'enter' === key.name) {
44
- process.stdin.off('keypress', onPromptKey);
45
- process.stdout.write('\n');
46
- const value = '' === buffer.trim() ? void 0 : buffer.trim();
47
- isPrompting = false;
48
- await onComplete(value);
49
- return;
50
- }
51
- if ('escape' === key.name) {
52
- clearCurrentInputLine();
53
- process.stdin.off('keypress', onPromptKey);
54
- isPrompting = false;
55
- return;
56
- }
57
- if ('backspace' === key.name) {
58
- buffer = buffer.slice(0, -1);
59
- render();
60
- return;
61
- }
62
- if ('string' == typeof str && 1 === str.length) {
63
- buffer += str;
64
- render();
65
- }
66
- };
67
- process.stdin.on('keypress', onPromptKey);
68
- };
69
- const shortcuts = [
70
- {
71
- key: 'f',
72
- description: `${utils.yW.bold('f')} ${utils.yW.dim('rerun failed tests')}`,
73
- action: async ()=>{
74
- await runFailedTests();
75
- }
76
- },
77
- {
78
- key: 'a',
79
- description: `${utils.yW.bold('a')} ${utils.yW.dim('rerun all tests')}`,
80
- action: async ()=>{
81
- await runAll();
82
- }
83
- },
84
- {
85
- key: 'u',
86
- description: `${utils.yW.bold('u')} ${utils.yW.dim('update snapshot')}`,
87
- action: async ()=>{
88
- await updateSnapshot();
89
- }
90
- },
91
- {
92
- key: 't',
93
- description: `${utils.yW.bold('t')} ${utils.yW.dim('filter by a test name regex pattern')}`,
94
- action: async ()=>{
95
- clearCurrentInputLine();
96
- await promptInput('Enter test name pattern (empty to clear): ', async (pattern)=>{
97
- await runWithTestNamePattern(pattern);
98
- });
99
- }
100
- },
101
- {
102
- key: 'p',
103
- description: `${utils.yW.bold('p')} ${utils.yW.dim('filter by a filename regex pattern')}`,
104
- action: async ()=>{
105
- clearCurrentInputLine();
106
- await promptInput('Enter file name pattern (empty to clear): ', async (input)=>{
107
- const filters = input ? input.split(/\s+/).filter(Boolean) : void 0;
108
- await runWithFileFilters(filters);
109
- });
110
- }
111
- },
112
- {
113
- key: 'c',
114
- description: `${utils.yW.bold('c')} ${utils.yW.dim('clear screen')}`,
115
- action: ()=>{
116
- (0, utils.mT)(true);
117
- }
118
- },
119
- {
120
- key: 'q',
121
- description: `${utils.yW.bold('q')} ${utils.yW.dim('quit process')}`,
122
- action: async ()=>{
123
- try {
124
- await closeServer();
125
- } finally{
126
- process.exit(0);
127
- }
128
- }
129
- }
130
- ];
131
- const handleKeypress = (str, key)=>{
132
- if (isPrompting) return;
133
- if (key.ctrl && 'c' === key.name) process.exit(0);
134
- for (const shortcut of shortcuts)if (str === shortcut.key) {
135
- clearCurrentInputLine();
136
- shortcut.action();
137
- return;
138
- }
139
- if ('h' === str) {
140
- clearCurrentInputLine();
141
- let message = ` ${utils.yW.bold(utils.yW.blue('Shortcuts:'))}\n`;
142
- for (const shortcut of shortcuts)message += ` ${shortcut.description}\n`;
143
- utils.vF.log(message);
144
- }
145
- };
146
- process.stdin.on('keypress', handleKeypress);
147
- return ()=>{
148
- try {
149
- process.stdin.setRawMode(false);
150
- process.stdin.pause();
151
- } catch {}
152
- process.stdin.off('keypress', handleKeypress);
153
- rl.close();
154
- };
155
- }
156
- var rsbuild = __webpack_require__("./src/core/rsbuild.ts");
157
- async function runTests(context) {
158
- const { rootPath, reporters, projects, snapshotManager, command, normalizedConfig: { coverage } } = context;
159
- const entriesCache = new Map();
160
- const globTestSourceEntries = async (name)=>{
161
- const { include, exclude, includeSource, root } = projects.find((p)=>p.environmentName === name).normalizedConfig;
162
- const entries = await (0, utils.tG)({
163
- include,
164
- exclude: exclude.patterns,
165
- includeSource,
166
- rootPath,
167
- projectRoot: root,
168
- fileFilters: context.fileFilters || []
169
- });
170
- entriesCache.set(name, {
171
- entries,
172
- fileFilters: context.fileFilters
173
- });
174
- return entries;
175
- };
176
- const setupFiles = Object.fromEntries(context.projects.map((project)=>{
177
- const { environmentName, rootPath, normalizedConfig: { setupFiles } } = project;
178
- return [
179
- environmentName,
180
- (0, utils.pr)(setupFiles, rootPath)
181
- ];
182
- }));
183
- const rsbuildInstance = await (0, rsbuild.zh)(context, globTestSourceEntries, setupFiles);
184
- const { getRsbuildStats, closeServer } = await (0, rsbuild.XD)({
185
- inspectedConfig: {
186
- ...context.normalizedConfig,
187
- projects: context.projects.map((p)=>p.normalizedConfig)
188
- },
189
- globTestSourceEntries: 'watch' === command ? globTestSourceEntries : async (name)=>{
190
- if (entriesCache.has(name)) return entriesCache.get(name).entries;
191
- return globTestSourceEntries(name);
192
- },
193
- setupFiles,
194
- rsbuildInstance,
195
- rootPath
196
- });
197
- const recommendWorkerCount = 'watch' === command ? 1 / 0 : Array.from(entriesCache.values()).reduce((acc, entry)=>acc + Object.keys(entry.entries).length, 0);
198
- const pool = await (0, src_pool.b)({
199
- context,
200
- recommendWorkerCount
201
- });
202
- const coverageProvider = coverage.enabled ? await (0, src_coverage.e)(coverage, context.rootPath) : null;
203
- if (coverageProvider) utils.vF.log(` ${utils.yW.gray('Coverage enabled with')} %s\n`, utils.yW.yellow(coverage.provider));
204
- const run = async ({ fileFilters, mode = 'all' } = {})=>{
205
- let testStart;
206
- const buildStart = Date.now();
207
- const currentEntries = [];
208
- const currentDeletedEntries = [];
209
- const returns = await Promise.all(context.projects.map(async (p)=>{
210
- const { assetNames, entries, setupEntries, getAssetFiles, getSourceMaps, affectedEntries, deletedEntries } = await getRsbuildStats({
211
- environmentName: p.environmentName,
212
- fileFilters
213
- });
214
- testStart ??= Date.now();
215
- currentDeletedEntries.push(...deletedEntries);
216
- let finalEntries = entries;
217
- if ('on-demand' === mode) {
218
- if (0 === affectedEntries.length) utils.vF.debug(utils.yW.yellow(`No test files need re-run in project(${p.environmentName}).`));
219
- else utils.vF.debug(utils.yW.yellow(`Test files to re-run in project(${p.environmentName}):\n`) + affectedEntries.map((e)=>e.testPath).join('\n') + '\n');
220
- finalEntries = affectedEntries;
221
- } else utils.vF.debug(utils.yW.yellow(fileFilters?.length ? `Run filtered tests in project(${p.environmentName}).\n` : `Run all tests in project(${p.environmentName}).\n`));
222
- currentEntries.push(...finalEntries);
223
- const { results, testResults } = await pool.runTests({
224
- entries: finalEntries,
225
- getSourceMaps,
226
- setupEntries,
227
- getAssetFiles,
228
- project: p,
229
- updateSnapshot: context.snapshotManager.options.updateSnapshot
230
- });
231
- return {
232
- results,
233
- testResults,
234
- assetNames,
235
- getSourceMaps
236
- };
237
- }));
238
- const buildTime = testStart - buildStart;
239
- const testTime = Date.now() - testStart;
240
- const duration = {
241
- totalTime: testTime + buildTime,
242
- buildTime,
243
- testTime
244
- };
245
- const results = returns.flatMap((r)=>r.results);
246
- const testResults = returns.flatMap((r)=>r.testResults);
247
- context.updateReporterResultState(results, testResults, currentDeletedEntries);
248
- if (0 === results.length) {
249
- if ('watch' === command) if ('on-demand' === mode) utils.vF.log(utils.yW.yellow('No test files need re-run.'));
250
- else utils.vF.log(utils.yW.yellow('No test files found.'));
251
- else {
252
- const code = context.normalizedConfig.passWithNoTests ? 0 : 1;
253
- utils.vF.log(utils.yW[code ? 'red' : 'yellow'](`No test files found, exiting with code ${code}.`));
254
- process.exitCode = code;
255
- }
256
- if ('all' === mode) {
257
- if (context.fileFilters?.length) utils.vF.log(utils.yW.gray('filter: '), context.fileFilters.join(utils.yW.gray(', ')));
258
- context.projects.forEach((p)=>{
259
- if (context.projects.length > 1) {
260
- utils.vF.log('');
261
- utils.vF.log(utils.yW.gray('project:'), p.name);
262
- }
263
- utils.vF.log(utils.yW.gray('include:'), p.normalizedConfig.include.join(utils.yW.gray(', ')));
264
- utils.vF.log(utils.yW.gray('exclude:'), p.normalizedConfig.exclude.patterns.join(utils.yW.gray(', ')));
265
- });
266
- }
267
- }
268
- const isFailure = results.some((r)=>'fail' === r.status);
269
- if (isFailure) process.exitCode = 1;
270
- for (const reporter of reporters)await reporter.onTestRunEnd?.({
271
- results: context.reporterResults.results,
272
- testResults: context.reporterResults.testResults,
273
- snapshotSummary: snapshotManager.summary,
274
- duration,
275
- getSourcemap: async (name)=>{
276
- const resource = returns.find((r)=>r.assetNames.includes(name));
277
- const sourceMap = (await resource?.getSourceMaps([
278
- name
279
- ]))?.[name];
280
- return sourceMap ? JSON.parse(sourceMap) : null;
281
- },
282
- filterRerunTestPaths: currentEntries.length ? currentEntries.map((e)=>e.testPath) : void 0
283
- });
284
- if (coverageProvider && (!isFailure || coverage.reportOnFailure)) {
285
- const { generateCoverage } = await __webpack_require__.e("204").then(__webpack_require__.bind(__webpack_require__, "./src/coverage/generate.ts"));
286
- await generateCoverage(context, results, coverageProvider);
287
- }
288
- };
289
- if ('watch' === command) {
290
- const enableCliShortcuts = isCliShortcutsEnabled();
291
- const afterTestsWatchRun = ()=>{
292
- utils.vF.log(utils.yW.green(' Waiting for file changes...'));
293
- if (enableCliShortcuts) if (snapshotManager.summary.unmatched) utils.vF.log(` ${utils.yW.dim('press')} ${utils.yW.yellow(utils.yW.bold('u'))} ${utils.yW.dim('to update snapshot')}${utils.yW.dim(', press')} ${utils.yW.bold('h')} ${utils.yW.dim('to show help')}\n`);
294
- else utils.vF.log(` ${utils.yW.dim('press')} ${utils.yW.bold('h')} ${utils.yW.dim('to show help')}${utils.yW.dim(', press')} ${utils.yW.bold('q')} ${utils.yW.dim('to quit')}\n`);
295
- };
296
- const { onBeforeRestart } = await __webpack_require__.e("967").then(__webpack_require__.bind(__webpack_require__, "./src/core/restart.ts"));
297
- onBeforeRestart(async ()=>{
298
- await pool.close();
299
- await closeServer();
300
- });
301
- rsbuildInstance.onBeforeDevCompile(({ isFirstCompile })=>{
302
- if (!isFirstCompile) (0, utils.mT)();
303
- });
304
- rsbuildInstance.onAfterDevCompile(async ({ isFirstCompile })=>{
305
- snapshotManager.clear();
306
- await run({
307
- mode: isFirstCompile ? 'all' : 'on-demand'
308
- });
309
- if (isFirstCompile && enableCliShortcuts) {
310
- const closeCliShortcuts = await setupCliShortcuts({
311
- closeServer: async ()=>{
312
- await pool.close();
313
- await closeServer();
314
- },
315
- runAll: async ()=>{
316
- (0, utils.mT)();
317
- snapshotManager.clear();
318
- context.normalizedConfig.testNamePattern = void 0;
319
- context.fileFilters = void 0;
320
- await run({
321
- mode: 'all'
322
- });
323
- afterTestsWatchRun();
324
- },
325
- runWithTestNamePattern: async (pattern)=>{
326
- (0, utils.mT)();
327
- context.normalizedConfig.testNamePattern = pattern;
328
- if (pattern) utils.vF.log(`\n${utils.yW.dim('Applied testNamePattern:')} ${utils.yW.bold(pattern)}\n`);
329
- else utils.vF.log(`\n${utils.yW.dim('Cleared testNamePattern filter')}\n`);
330
- snapshotManager.clear();
331
- await run();
332
- afterTestsWatchRun();
333
- },
334
- runWithFileFilters: async (filters)=>{
335
- (0, utils.mT)();
336
- if (filters && filters.length > 0) utils.vF.log(`\n${utils.yW.dim('Applied file filters:')} ${utils.yW.bold(filters.join(', '))}\n`);
337
- else utils.vF.log(`\n${utils.yW.dim('Cleared file filters')}\n`);
338
- snapshotManager.clear();
339
- context.fileFilters = filters;
340
- const entries = await Promise.all(projects.map(async (p)=>globTestSourceEntries(p.environmentName))).then((entries)=>entries.reduce((acc, entry)=>acc.concat(...Object.values(entry)), []));
341
- if (!entries.length) return void utils.vF.log(filters ? utils.yW.yellow(`\nNo matching test files to run with current file filters: ${filters.join(',')}\n`) : utils.yW.yellow('\nNo matching test files to run.\n'));
342
- await run({
343
- fileFilters: entries
344
- });
345
- afterTestsWatchRun();
346
- },
347
- runFailedTests: async ()=>{
348
- const failedTests = context.reporterResults.results.filter((result)=>'fail' === result.status).map((r)=>r.testPath);
349
- if (!failedTests.length) return void utils.vF.log(utils.yW.yellow('\nNo failed tests were found that needed to be rerun.'));
350
- (0, utils.mT)();
351
- snapshotManager.clear();
352
- await run({
353
- fileFilters: failedTests,
354
- mode: 'all'
355
- });
356
- afterTestsWatchRun();
357
- },
358
- updateSnapshot: async ()=>{
359
- if (!snapshotManager.summary.unmatched) return void utils.vF.log(utils.yW.yellow('\nNo snapshots were found that needed to be updated.'));
360
- const failedTests = context.reporterResults.results.filter((result)=>result.snapshotResult?.unmatched).map((r)=>r.testPath);
361
- (0, utils.mT)();
362
- const originalUpdateSnapshot = snapshotManager.options.updateSnapshot;
363
- snapshotManager.clear();
364
- snapshotManager.options.updateSnapshot = 'all';
365
- await run({
366
- fileFilters: failedTests
367
- });
368
- afterTestsWatchRun();
369
- snapshotManager.options.updateSnapshot = originalUpdateSnapshot;
370
- }
371
- });
372
- onBeforeRestart(closeCliShortcuts);
373
- }
374
- afterTestsWatchRun();
375
- });
376
- } else {
377
- await run();
378
- await pool.close();
379
- await closeServer();
380
- }
381
- }
382
- },
383
- "./src/coverage/index.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
384
- __webpack_require__.d(__webpack_exports__, {
385
- e: ()=>createCoverageProvider,
386
- loadCoverageProvider: ()=>loadCoverageProvider
387
- });
388
- var node_module__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("node:module");
389
- var node_url__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("node:url");
390
- var _utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./src/utils/index.ts");
391
- const CoverageProviderMap = {
392
- istanbul: '@rstest/coverage-istanbul'
393
- };
394
- const loadCoverageProvider = async (options, root)=>{
395
- const rootPath = (0, node_url__WEBPACK_IMPORTED_MODULE_1__.pathToFileURL)(root).toString();
396
- const moduleName = CoverageProviderMap[options.provider || 'istanbul'];
397
- if (!moduleName) throw new Error(`Unknown coverage provider: ${options.provider}`);
398
- try {
399
- const require = (0, node_module__WEBPACK_IMPORTED_MODULE_0__.createRequire)(rootPath);
400
- const modulePath = require.resolve(moduleName, {
401
- paths: [
402
- rootPath
403
- ]
404
- });
405
- const { pluginCoverage, CoverageProvider } = await import((0, node_url__WEBPACK_IMPORTED_MODULE_1__.pathToFileURL)(modulePath).toString());
406
- return {
407
- pluginCoverage,
408
- CoverageProvider
409
- };
410
- } catch {
411
- const error = new Error(`Failed to load coverage provider module: ${_utils__WEBPACK_IMPORTED_MODULE_2__.yW.cyan(moduleName)} in ${_utils__WEBPACK_IMPORTED_MODULE_2__.yW.underline(root)}, please make sure it is installed.\n`);
412
- error.stack = '';
413
- throw error;
414
- }
415
- };
416
- async function createCoverageProvider(options, root) {
417
- if (!options.enabled) return null;
418
- if (!options.provider || CoverageProviderMap[options.provider]) {
419
- const { CoverageProvider } = await loadCoverageProvider(options, root);
420
- return new CoverageProvider(options);
421
- }
422
- throw new Error(`Unknown coverage provider: ${options.provider}`);
423
- }
424
- }
425
- };
package/dist/0~414.js DELETED
@@ -1,16 +0,0 @@
1
- import 'module';
2
- /*#__PURE__*/ import.meta.url;
3
- import * as __WEBPACK_EXTERNAL_MODULE_fs_promises_400951f8__ from "fs/promises";
4
- import * as __WEBPACK_EXTERNAL_MODULE_node_stream_444d1c2b__ from "node:stream";
5
- export const __webpack_id__ = "414";
6
- export const __webpack_ids__ = [
7
- "414"
8
- ];
9
- export const __webpack_modules__ = {
10
- "fs/promises": function(module) {
11
- module.exports = __WEBPACK_EXTERNAL_MODULE_fs_promises_400951f8__;
12
- },
13
- "node:stream": function(module) {
14
- module.exports = __WEBPACK_EXTERNAL_MODULE_node_stream_444d1c2b__;
15
- }
16
- };