@rstest/core 0.9.2 → 0.9.4
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.
- package/LICENSE.md +1 -1
- package/dist/0~8843.js +15 -9
- package/dist/0~browserLoader.js +8 -8
- package/dist/0~browser~1.js +31 -31
- package/dist/0~checkThresholds.js +5 -5
- package/dist/{0~esm.js → 0~chokidar.js} +61 -18
- package/dist/0~console.js +7 -7
- package/dist/0~generate.js +4 -0
- package/dist/0~listTests.js +13 -9
- package/dist/0~loadEsModule.js +3 -1
- package/dist/0~mergeReports.js +127 -0
- package/dist/0~restart.js +3 -3
- package/dist/0~runTests.js +47 -43
- package/dist/1949.js +27 -11
- package/dist/255.js +3 -3
- package/dist/3145.js +203 -106
- package/dist/4411.js +3 -3
- package/dist/6830.js +43 -28
- package/dist/7552.js +82 -65
- package/dist/7704.js +3 -4
- package/dist/browser-runtime/723.js +142 -93
- package/dist/browser-runtime/index.d.ts +40 -5
- package/dist/browser.d.ts +40 -5
- package/dist/globalSetupWorker.js +4 -2
- package/dist/index.d.ts +53 -6
- package/dist/worker.d.ts +30 -3
- package/dist/worker.js +23 -4
- package/package.json +19 -18
- /package/dist/{0~esm.js.LICENSE.txt → 0~chokidar.js.LICENSE.txt} +0 -0
|
@@ -281,6 +281,14 @@ export declare const beforeEach: Rstest['beforeEach'];
|
|
|
281
281
|
|
|
282
282
|
declare type BeforeEachListener = (ctx: TestContext) => MaybePromise<void | AfterEachListener>;
|
|
283
283
|
|
|
284
|
+
declare type BlobReporterOptions = {
|
|
285
|
+
/**
|
|
286
|
+
* Directory to store blob report files.
|
|
287
|
+
* @default '.rstest-reports'
|
|
288
|
+
*/
|
|
289
|
+
outputDir?: string;
|
|
290
|
+
};
|
|
291
|
+
|
|
284
292
|
declare interface BranchMapping {
|
|
285
293
|
loc: Range_2;
|
|
286
294
|
type: string;
|
|
@@ -331,6 +339,13 @@ declare type BrowserModeConfig = {
|
|
|
331
339
|
* @default false
|
|
332
340
|
*/
|
|
333
341
|
strictPort?: boolean;
|
|
342
|
+
/**
|
|
343
|
+
* Provider-specific config passed through to the selected browser provider.
|
|
344
|
+
*
|
|
345
|
+
* Use provider-owned types or helpers in user config when you want richer
|
|
346
|
+
* IntelliSense for this field.
|
|
347
|
+
*/
|
|
348
|
+
providerOptions?: Record<string, unknown>;
|
|
334
349
|
};
|
|
335
350
|
|
|
336
351
|
/**
|
|
@@ -347,7 +362,7 @@ declare type BrowserViewport = {
|
|
|
347
362
|
height: number;
|
|
348
363
|
} | DevicePreset;
|
|
349
364
|
|
|
350
|
-
declare type BuiltInReporterNames = 'default' | 'verbose' | 'md' | 'github-actions' | 'junit';
|
|
365
|
+
declare type BuiltInReporterNames = 'default' | 'verbose' | 'md' | 'github-actions' | 'junit' | 'blob';
|
|
351
366
|
|
|
352
367
|
declare type BuiltinReporterOptions = {
|
|
353
368
|
default: DefaultReporterOptions;
|
|
@@ -355,6 +370,7 @@ declare type BuiltinReporterOptions = {
|
|
|
355
370
|
md: MdReporterOptions;
|
|
356
371
|
'github-actions': Record<string, unknown>;
|
|
357
372
|
junit: Record<string, unknown>;
|
|
373
|
+
blob: BlobReporterOptions;
|
|
358
374
|
};
|
|
359
375
|
|
|
360
376
|
declare type ChaiConfig = Partial<Omit<typeof config, 'useProxy' | 'proxyExcludedKeys' | 'deepEqual'>>;
|
|
@@ -509,6 +525,12 @@ declare type CoverageOptions = {
|
|
|
509
525
|
* @default false
|
|
510
526
|
*/
|
|
511
527
|
reportOnFailure?: boolean;
|
|
528
|
+
/**
|
|
529
|
+
* Whether to collect coverage for source files outside the project root directory.
|
|
530
|
+
* This is useful in monorepo setups where tests import modules from sibling packages.
|
|
531
|
+
* @default false
|
|
532
|
+
*/
|
|
533
|
+
allowExternal?: boolean;
|
|
512
534
|
};
|
|
513
535
|
|
|
514
536
|
declare class CoverageSummary {
|
|
@@ -638,11 +660,15 @@ declare interface DescribeEachFn {
|
|
|
638
660
|
<T extends Record<string, unknown>>(cases: readonly T[]): (description: string, fn?: (param: T) => MaybePromise<void>) => void;
|
|
639
661
|
<T extends readonly [unknown, ...unknown[]]>(cases: readonly T[]): (description: string, fn: (...args: [...T]) => MaybePromise<void>) => void;
|
|
640
662
|
<T>(cases: readonly T[]): (description: string, fn: (param: T) => MaybePromise<void>) => void;
|
|
663
|
+
<T extends Record<string, unknown>>(strings: TemplateStringsArray, ...expressions: unknown[]): (description: string, fn?: (param: T) => MaybePromise<void>) => void;
|
|
641
664
|
}
|
|
642
665
|
|
|
643
666
|
declare type DescribeFn = (description: string, fn?: () => void) => void;
|
|
644
667
|
|
|
645
|
-
declare
|
|
668
|
+
declare interface DescribeForFn {
|
|
669
|
+
<T>(cases: readonly T[]): (description: string, fn?: (param: T) => MaybePromise<void>) => void;
|
|
670
|
+
<T extends Record<string, unknown>>(strings: TemplateStringsArray, ...expressions: unknown[]): (description: string, fn?: (param: T) => MaybePromise<void>) => void;
|
|
671
|
+
}
|
|
646
672
|
|
|
647
673
|
/**
|
|
648
674
|
* Device presets aligned with Chrome DevTools device toolbar.
|
|
@@ -1713,6 +1739,7 @@ declare type NormalizedBrowserModeConfig = {
|
|
|
1713
1739
|
port?: number;
|
|
1714
1740
|
strictPort: boolean;
|
|
1715
1741
|
viewport?: BrowserViewport;
|
|
1742
|
+
providerOptions: Record<string, unknown>;
|
|
1716
1743
|
};
|
|
1717
1744
|
|
|
1718
1745
|
declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects' | 'coverage' | 'setupFiles' | 'globalSetup' | 'exclude' | 'testEnvironment' | 'browser'>> & Partial<Pick<RstestConfig, OptionalKeys>> & {
|
|
@@ -1939,13 +1966,13 @@ declare type Rstest = RunnerAPI & {
|
|
|
1939
1966
|
|
|
1940
1967
|
export declare const rstest: RstestUtilities;
|
|
1941
1968
|
|
|
1942
|
-
declare type RstestCommand = 'watch' | 'run' | 'list';
|
|
1969
|
+
declare type RstestCommand = 'watch' | 'run' | 'list' | 'merge-reports';
|
|
1943
1970
|
|
|
1944
1971
|
declare interface RstestConfig {
|
|
1945
1972
|
/**
|
|
1946
1973
|
* Extend configuration from adapters
|
|
1947
1974
|
*/
|
|
1948
|
-
extends?: ExtendConfigFn | ExtendConfig;
|
|
1975
|
+
extends?: ExtendConfigFn | ExtendConfig | (ExtendConfigFn | ExtendConfig)[];
|
|
1949
1976
|
/**
|
|
1950
1977
|
* Project root
|
|
1951
1978
|
*
|
|
@@ -2204,6 +2231,10 @@ declare type RstestContext = {
|
|
|
2204
2231
|
reporters: Reporter[];
|
|
2205
2232
|
snapshotManager: SnapshotManager;
|
|
2206
2233
|
stateManager: TestStateManager;
|
|
2234
|
+
reporterResults: {
|
|
2235
|
+
results: TestFileResult[];
|
|
2236
|
+
testResults: TestResult[];
|
|
2237
|
+
};
|
|
2207
2238
|
};
|
|
2208
2239
|
|
|
2209
2240
|
declare type RstestExpect = ExpectStatic;
|
|
@@ -2810,6 +2841,7 @@ declare interface TestEachFn {
|
|
|
2810
2841
|
<T extends Record<string, unknown>>(cases: readonly T[]): (description: string, fn?: (param: T) => MaybePromise<void>, timeout?: number) => void;
|
|
2811
2842
|
<T extends readonly [unknown, ...unknown[]]>(cases: readonly T[]): (description: string, fn: (...args: [...T]) => MaybePromise<void>, timeout?: number) => void;
|
|
2812
2843
|
<T>(cases: readonly T[]): (description: string, fn: (...args: T[]) => MaybePromise<void>, timeout?: number) => void;
|
|
2844
|
+
<T extends Record<string, unknown>>(strings: TemplateStringsArray, ...expressions: unknown[]): (description: string, fn?: (param: T) => MaybePromise<void>, timeout?: number) => void;
|
|
2813
2845
|
}
|
|
2814
2846
|
|
|
2815
2847
|
declare type Tester = (this: TesterContext, a: any, b: any, customTesters: Array<Tester>) => boolean | undefined;
|
|
@@ -2831,7 +2863,10 @@ export declare type TestFileResult = TestResult & {
|
|
|
2831
2863
|
|
|
2832
2864
|
declare type TestFn<ExtraContext = object> = (description: string, fn?: TestCallbackFn<ExtraContext>, timeout?: number) => void;
|
|
2833
2865
|
|
|
2834
|
-
declare
|
|
2866
|
+
declare interface TestForFn<ExtraContext = object> {
|
|
2867
|
+
<T>(cases: readonly T[]): (description: string, fn?: (param: T, context: TestContext & ExtraContext) => MaybePromise<void>, timeout?: number) => void;
|
|
2868
|
+
<T extends Record<string, unknown>>(strings: TemplateStringsArray, ...expressions: unknown[]): (description: string, fn?: (param: T, context: TestContext & ExtraContext) => MaybePromise<void>, timeout?: number) => void;
|
|
2869
|
+
}
|
|
2835
2870
|
|
|
2836
2871
|
export declare type TestInfo = TestCaseInfo | (TestSuiteInfo & {
|
|
2837
2872
|
tests: TestInfo[];
|
package/dist/browser.d.ts
CHANGED
|
@@ -277,6 +277,14 @@ export declare const beforeEach: Rstest_2['beforeEach'];
|
|
|
277
277
|
|
|
278
278
|
declare type BeforeEachListener = (ctx: TestContext) => MaybePromise<void | AfterEachListener>;
|
|
279
279
|
|
|
280
|
+
declare type BlobReporterOptions = {
|
|
281
|
+
/**
|
|
282
|
+
* Directory to store blob report files.
|
|
283
|
+
* @default '.rstest-reports'
|
|
284
|
+
*/
|
|
285
|
+
outputDir?: string;
|
|
286
|
+
};
|
|
287
|
+
|
|
280
288
|
declare interface BranchMapping {
|
|
281
289
|
loc: Range_2;
|
|
282
290
|
type: string;
|
|
@@ -327,6 +335,13 @@ declare type BrowserModeConfig = {
|
|
|
327
335
|
* @default false
|
|
328
336
|
*/
|
|
329
337
|
strictPort?: boolean;
|
|
338
|
+
/**
|
|
339
|
+
* Provider-specific config passed through to the selected browser provider.
|
|
340
|
+
*
|
|
341
|
+
* Use provider-owned types or helpers in user config when you want richer
|
|
342
|
+
* IntelliSense for this field.
|
|
343
|
+
*/
|
|
344
|
+
providerOptions?: Record<string, unknown>;
|
|
330
345
|
};
|
|
331
346
|
|
|
332
347
|
/**
|
|
@@ -393,7 +408,7 @@ declare type BrowserViewport = {
|
|
|
393
408
|
height: number;
|
|
394
409
|
} | DevicePreset;
|
|
395
410
|
|
|
396
|
-
declare type BuiltInReporterNames = 'default' | 'verbose' | 'md' | 'github-actions' | 'junit';
|
|
411
|
+
declare type BuiltInReporterNames = 'default' | 'verbose' | 'md' | 'github-actions' | 'junit' | 'blob';
|
|
397
412
|
|
|
398
413
|
declare type BuiltinReporterOptions = {
|
|
399
414
|
default: DefaultReporterOptions;
|
|
@@ -401,6 +416,7 @@ declare type BuiltinReporterOptions = {
|
|
|
401
416
|
md: MdReporterOptions;
|
|
402
417
|
'github-actions': Record<string, unknown>;
|
|
403
418
|
junit: Record<string, unknown>;
|
|
419
|
+
blob: BlobReporterOptions;
|
|
404
420
|
};
|
|
405
421
|
|
|
406
422
|
declare type ChaiConfig = Partial<Omit<typeof config, 'useProxy' | 'proxyExcludedKeys' | 'deepEqual'>>;
|
|
@@ -624,6 +640,12 @@ declare type CoverageOptions = {
|
|
|
624
640
|
* @default false
|
|
625
641
|
*/
|
|
626
642
|
reportOnFailure?: boolean;
|
|
643
|
+
/**
|
|
644
|
+
* Whether to collect coverage for source files outside the project root directory.
|
|
645
|
+
* This is useful in monorepo setups where tests import modules from sibling packages.
|
|
646
|
+
* @default false
|
|
647
|
+
*/
|
|
648
|
+
allowExternal?: boolean;
|
|
627
649
|
};
|
|
628
650
|
|
|
629
651
|
declare class CoverageProvider {
|
|
@@ -784,11 +806,15 @@ declare interface DescribeEachFn {
|
|
|
784
806
|
<T extends Record<string, unknown>>(cases: readonly T[]): (description: string, fn?: (param: T) => MaybePromise<void>) => void;
|
|
785
807
|
<T extends readonly [unknown, ...unknown[]]>(cases: readonly T[]): (description: string, fn: (...args: [...T]) => MaybePromise<void>) => void;
|
|
786
808
|
<T>(cases: readonly T[]): (description: string, fn: (param: T) => MaybePromise<void>) => void;
|
|
809
|
+
<T extends Record<string, unknown>>(strings: TemplateStringsArray, ...expressions: unknown[]): (description: string, fn?: (param: T) => MaybePromise<void>) => void;
|
|
787
810
|
}
|
|
788
811
|
|
|
789
812
|
declare type DescribeFn = (description: string, fn?: () => void) => void;
|
|
790
813
|
|
|
791
|
-
declare
|
|
814
|
+
declare interface DescribeForFn {
|
|
815
|
+
<T>(cases: readonly T[]): (description: string, fn?: (param: T) => MaybePromise<void>) => void;
|
|
816
|
+
<T extends Record<string, unknown>>(strings: TemplateStringsArray, ...expressions: unknown[]): (description: string, fn?: (param: T) => MaybePromise<void>) => void;
|
|
817
|
+
}
|
|
792
818
|
|
|
793
819
|
/**
|
|
794
820
|
* Device presets aligned with Chrome DevTools device toolbar.
|
|
@@ -2241,6 +2267,7 @@ declare type NormalizedBrowserModeConfig = {
|
|
|
2241
2267
|
port?: number;
|
|
2242
2268
|
strictPort: boolean;
|
|
2243
2269
|
viewport?: BrowserViewport;
|
|
2270
|
+
providerOptions: Record<string, unknown>;
|
|
2244
2271
|
};
|
|
2245
2272
|
|
|
2246
2273
|
declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects' | 'coverage' | 'setupFiles' | 'globalSetup' | 'exclude' | 'testEnvironment' | 'browser'>> & Partial<Pick<RstestConfig, OptionalKeys>> & {
|
|
@@ -2550,13 +2577,13 @@ declare type Rstest_2 = RunnerAPI & {
|
|
|
2550
2577
|
rs: RstestUtilities;
|
|
2551
2578
|
};
|
|
2552
2579
|
|
|
2553
|
-
declare type RstestCommand = 'watch' | 'run' | 'list';
|
|
2580
|
+
declare type RstestCommand = 'watch' | 'run' | 'list' | 'merge-reports';
|
|
2554
2581
|
|
|
2555
2582
|
declare interface RstestConfig {
|
|
2556
2583
|
/**
|
|
2557
2584
|
* Extend configuration from adapters
|
|
2558
2585
|
*/
|
|
2559
|
-
extends?: ExtendConfigFn | ExtendConfig;
|
|
2586
|
+
extends?: ExtendConfigFn | ExtendConfig | (ExtendConfigFn | ExtendConfig)[];
|
|
2560
2587
|
/**
|
|
2561
2588
|
* Project root
|
|
2562
2589
|
*
|
|
@@ -2815,6 +2842,10 @@ declare type RstestContext = {
|
|
|
2815
2842
|
reporters: Reporter[];
|
|
2816
2843
|
snapshotManager: SnapshotManager;
|
|
2817
2844
|
stateManager: TestStateManager;
|
|
2845
|
+
reporterResults: {
|
|
2846
|
+
results: TestFileResult[];
|
|
2847
|
+
testResults: TestResult[];
|
|
2848
|
+
};
|
|
2818
2849
|
};
|
|
2819
2850
|
|
|
2820
2851
|
declare type RstestExpect = ExpectStatic;
|
|
@@ -3437,6 +3468,7 @@ declare interface TestEachFn {
|
|
|
3437
3468
|
<T extends Record<string, unknown>>(cases: readonly T[]): (description: string, fn?: (param: T) => MaybePromise<void>, timeout?: number) => void;
|
|
3438
3469
|
<T extends readonly [unknown, ...unknown[]]>(cases: readonly T[]): (description: string, fn: (...args: [...T]) => MaybePromise<void>, timeout?: number) => void;
|
|
3439
3470
|
<T>(cases: readonly T[]): (description: string, fn: (...args: T[]) => MaybePromise<void>, timeout?: number) => void;
|
|
3471
|
+
<T extends Record<string, unknown>>(strings: TemplateStringsArray, ...expressions: unknown[]): (description: string, fn?: (param: T) => MaybePromise<void>, timeout?: number) => void;
|
|
3440
3472
|
}
|
|
3441
3473
|
|
|
3442
3474
|
declare type Tester = (this: TesterContext, a: any, b: any, customTesters: Array<Tester>) => boolean | undefined;
|
|
@@ -3458,7 +3490,10 @@ export declare type TestFileResult = TestResult & {
|
|
|
3458
3490
|
|
|
3459
3491
|
declare type TestFn<ExtraContext = object> = (description: string, fn?: TestCallbackFn<ExtraContext>, timeout?: number) => void;
|
|
3460
3492
|
|
|
3461
|
-
declare
|
|
3493
|
+
declare interface TestForFn<ExtraContext = object> {
|
|
3494
|
+
<T>(cases: readonly T[]): (description: string, fn?: (param: T, context: TestContext & ExtraContext) => MaybePromise<void>, timeout?: number) => void;
|
|
3495
|
+
<T extends Record<string, unknown>>(strings: TemplateStringsArray, ...expressions: unknown[]): (description: string, fn?: (param: T, context: TestContext & ExtraContext) => MaybePromise<void>, timeout?: number) => void;
|
|
3496
|
+
}
|
|
3462
3497
|
|
|
3463
3498
|
declare type TestInfo = TestCaseInfo | (TestSuiteInfo & {
|
|
3464
3499
|
tests: TestInfo[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
3
3
|
import "./1255.js";
|
|
4
|
-
import { color } from "./6830.js";
|
|
4
|
+
import { color as logger_color } from "./6830.js";
|
|
5
5
|
import { formatTestError } from "./7552.js";
|
|
6
6
|
const source_map_support = __webpack_require__("../../node_modules/.pnpm/source-map-support@0.5.21/node_modules/source-map-support/source-map-support.js");
|
|
7
7
|
let teardownCallbacks = [];
|
|
@@ -82,6 +82,8 @@ async function runInPool(options) {
|
|
|
82
82
|
return runGlobalSetup(options);
|
|
83
83
|
case 'teardown':
|
|
84
84
|
return runGlobalTeardown();
|
|
85
|
+
default:
|
|
86
|
+
throw new Error(`Unknown worker type: ${options.type}`);
|
|
85
87
|
}
|
|
86
88
|
}
|
|
87
89
|
const runGlobalTeardown = async ()=>{
|
|
@@ -96,7 +98,7 @@ const runGlobalTeardown = async ()=>{
|
|
|
96
98
|
};
|
|
97
99
|
} catch (error) {
|
|
98
100
|
const message = error instanceof Error && error.stack ? error.stack : String(error);
|
|
99
|
-
console.error(
|
|
101
|
+
console.error(logger_color.red(`Error during global teardown: ${message}`));
|
|
100
102
|
return {
|
|
101
103
|
success: false
|
|
102
104
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -258,6 +258,14 @@ export declare const beforeEach: Rstest['beforeEach'];
|
|
|
258
258
|
|
|
259
259
|
declare type BeforeEachListener = (ctx: TestContext) => MaybePromise<void | AfterEachListener>;
|
|
260
260
|
|
|
261
|
+
declare type BlobReporterOptions = {
|
|
262
|
+
/**
|
|
263
|
+
* Directory to store blob report files.
|
|
264
|
+
* @default '.rstest-reports'
|
|
265
|
+
*/
|
|
266
|
+
outputDir?: string;
|
|
267
|
+
};
|
|
268
|
+
|
|
261
269
|
declare interface BranchMapping {
|
|
262
270
|
loc: Range_2;
|
|
263
271
|
type: string;
|
|
@@ -308,6 +316,13 @@ declare type BrowserModeConfig = {
|
|
|
308
316
|
* @default false
|
|
309
317
|
*/
|
|
310
318
|
strictPort?: boolean;
|
|
319
|
+
/**
|
|
320
|
+
* Provider-specific config passed through to the selected browser provider.
|
|
321
|
+
*
|
|
322
|
+
* Use provider-owned types or helpers in user config when you want richer
|
|
323
|
+
* IntelliSense for this field.
|
|
324
|
+
*/
|
|
325
|
+
providerOptions?: Record<string, unknown>;
|
|
311
326
|
};
|
|
312
327
|
|
|
313
328
|
/**
|
|
@@ -324,7 +339,7 @@ declare type BrowserViewport = {
|
|
|
324
339
|
height: number;
|
|
325
340
|
} | DevicePreset;
|
|
326
341
|
|
|
327
|
-
declare type BuiltInReporterNames = 'default' | 'verbose' | 'md' | 'github-actions' | 'junit';
|
|
342
|
+
declare type BuiltInReporterNames = 'default' | 'verbose' | 'md' | 'github-actions' | 'junit' | 'blob';
|
|
328
343
|
|
|
329
344
|
declare type BuiltinReporterOptions = {
|
|
330
345
|
default: DefaultReporterOptions;
|
|
@@ -332,6 +347,7 @@ declare type BuiltinReporterOptions = {
|
|
|
332
347
|
md: MdReporterOptions;
|
|
333
348
|
'github-actions': Record<string, unknown>;
|
|
334
349
|
junit: Record<string, unknown>;
|
|
350
|
+
blob: BlobReporterOptions;
|
|
335
351
|
};
|
|
336
352
|
|
|
337
353
|
declare type ChaiConfig = Partial<Omit<typeof config, 'useProxy' | 'proxyExcludedKeys' | 'deepEqual'>>;
|
|
@@ -402,7 +418,15 @@ declare type CommonOptions = {
|
|
|
402
418
|
exclude?: string[];
|
|
403
419
|
reporter?: string[];
|
|
404
420
|
project?: string[];
|
|
405
|
-
|
|
421
|
+
/**
|
|
422
|
+
* Coverage options.
|
|
423
|
+
* - `boolean`: shorthand for `{ enabled: boolean }` (from `--coverage` flag)
|
|
424
|
+
* - `object`: detailed coverage config (from `--coverage.*` options)
|
|
425
|
+
*/
|
|
426
|
+
coverage?: boolean | {
|
|
427
|
+
enabled?: boolean;
|
|
428
|
+
allowExternal?: boolean;
|
|
429
|
+
};
|
|
406
430
|
passWithNoTests?: boolean;
|
|
407
431
|
printConsoleTrace?: boolean;
|
|
408
432
|
logHeapUsage?: boolean;
|
|
@@ -607,6 +631,12 @@ export declare type CoverageOptions = {
|
|
|
607
631
|
* @default false
|
|
608
632
|
*/
|
|
609
633
|
reportOnFailure?: boolean;
|
|
634
|
+
/**
|
|
635
|
+
* Whether to collect coverage for source files outside the project root directory.
|
|
636
|
+
* This is useful in monorepo setups where tests import modules from sibling packages.
|
|
637
|
+
* @default false
|
|
638
|
+
*/
|
|
639
|
+
allowExternal?: boolean;
|
|
610
640
|
};
|
|
611
641
|
|
|
612
642
|
export declare class CoverageProvider {
|
|
@@ -786,11 +816,15 @@ declare interface DescribeEachFn {
|
|
|
786
816
|
<T extends Record<string, unknown>>(cases: readonly T[]): (description: string, fn?: (param: T) => MaybePromise<void>) => void;
|
|
787
817
|
<T extends readonly [unknown, ...unknown[]]>(cases: readonly T[]): (description: string, fn: (...args: [...T]) => MaybePromise<void>) => void;
|
|
788
818
|
<T>(cases: readonly T[]): (description: string, fn: (param: T) => MaybePromise<void>) => void;
|
|
819
|
+
<T extends Record<string, unknown>>(strings: TemplateStringsArray, ...expressions: unknown[]): (description: string, fn?: (param: T) => MaybePromise<void>) => void;
|
|
789
820
|
}
|
|
790
821
|
|
|
791
822
|
declare type DescribeFn = (description: string, fn?: () => void) => void;
|
|
792
823
|
|
|
793
|
-
declare
|
|
824
|
+
declare interface DescribeForFn {
|
|
825
|
+
<T>(cases: readonly T[]): (description: string, fn?: (param: T) => MaybePromise<void>) => void;
|
|
826
|
+
<T extends Record<string, unknown>>(strings: TemplateStringsArray, ...expressions: unknown[]): (description: string, fn?: (param: T) => MaybePromise<void>) => void;
|
|
827
|
+
}
|
|
794
828
|
|
|
795
829
|
/**
|
|
796
830
|
* Device presets aligned with Chrome DevTools device toolbar.
|
|
@@ -2249,6 +2283,7 @@ declare type NormalizedBrowserModeConfig = {
|
|
|
2249
2283
|
port?: number;
|
|
2250
2284
|
strictPort: boolean;
|
|
2251
2285
|
viewport?: BrowserViewport;
|
|
2286
|
+
providerOptions: Record<string, unknown>;
|
|
2252
2287
|
};
|
|
2253
2288
|
|
|
2254
2289
|
declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects' | 'coverage' | 'setupFiles' | 'globalSetup' | 'exclude' | 'testEnvironment' | 'browser'>> & Partial<Pick<RstestConfig, OptionalKeys>> & {
|
|
@@ -2523,13 +2558,13 @@ export declare type Rstest = RunnerAPI & {
|
|
|
2523
2558
|
|
|
2524
2559
|
export declare const rstest: RstestUtilities;
|
|
2525
2560
|
|
|
2526
|
-
export declare type RstestCommand = 'watch' | 'run' | 'list';
|
|
2561
|
+
export declare type RstestCommand = 'watch' | 'run' | 'list' | 'merge-reports';
|
|
2527
2562
|
|
|
2528
2563
|
export declare interface RstestConfig {
|
|
2529
2564
|
/**
|
|
2530
2565
|
* Extend configuration from adapters
|
|
2531
2566
|
*/
|
|
2532
|
-
extends?: ExtendConfigFn | ExtendConfig;
|
|
2567
|
+
extends?: ExtendConfigFn | ExtendConfig | (ExtendConfigFn | ExtendConfig)[];
|
|
2533
2568
|
/**
|
|
2534
2569
|
* Project root
|
|
2535
2570
|
*
|
|
@@ -2794,12 +2829,20 @@ declare type RstestContext = {
|
|
|
2794
2829
|
reporters: Reporter[];
|
|
2795
2830
|
snapshotManager: SnapshotManager;
|
|
2796
2831
|
stateManager: TestStateManager;
|
|
2832
|
+
reporterResults: {
|
|
2833
|
+
results: TestFileResult[];
|
|
2834
|
+
testResults: TestResult[];
|
|
2835
|
+
};
|
|
2797
2836
|
};
|
|
2798
2837
|
|
|
2799
2838
|
declare type RstestInstance = {
|
|
2800
2839
|
context: RstestContext;
|
|
2801
2840
|
runTests: () => Promise<void>;
|
|
2802
2841
|
listTests: (options: ListCommandOptions) => Promise<ListCommandResult[]>;
|
|
2842
|
+
mergeReports: (options?: {
|
|
2843
|
+
path?: string;
|
|
2844
|
+
cleanup?: boolean;
|
|
2845
|
+
}) => Promise<void>;
|
|
2803
2846
|
};
|
|
2804
2847
|
|
|
2805
2848
|
declare type RstestPoolOptions = {
|
|
@@ -3327,6 +3370,7 @@ declare interface TestEachFn {
|
|
|
3327
3370
|
<T extends Record<string, unknown>>(cases: readonly T[]): (description: string, fn?: (param: T) => MaybePromise<void>, timeout?: number) => void;
|
|
3328
3371
|
<T extends readonly [unknown, ...unknown[]]>(cases: readonly T[]): (description: string, fn: (...args: [...T]) => MaybePromise<void>, timeout?: number) => void;
|
|
3329
3372
|
<T>(cases: readonly T[]): (description: string, fn: (...args: T[]) => MaybePromise<void>, timeout?: number) => void;
|
|
3373
|
+
<T extends Record<string, unknown>>(strings: TemplateStringsArray, ...expressions: unknown[]): (description: string, fn?: (param: T) => MaybePromise<void>, timeout?: number) => void;
|
|
3330
3374
|
}
|
|
3331
3375
|
|
|
3332
3376
|
declare type Tester = (this: TesterContext, a: any, b: any, customTesters: Array<Tester>) => boolean | undefined;
|
|
@@ -3348,7 +3392,10 @@ export declare type TestFileResult = TestResult & {
|
|
|
3348
3392
|
|
|
3349
3393
|
declare type TestFn<ExtraContext = object> = (description: string, fn?: TestCallbackFn<ExtraContext>, timeout?: number) => void;
|
|
3350
3394
|
|
|
3351
|
-
declare
|
|
3395
|
+
declare interface TestForFn<ExtraContext = object> {
|
|
3396
|
+
<T>(cases: readonly T[]): (description: string, fn?: (param: T, context: TestContext & ExtraContext) => MaybePromise<void>, timeout?: number) => void;
|
|
3397
|
+
<T extends Record<string, unknown>>(strings: TemplateStringsArray, ...expressions: unknown[]): (description: string, fn?: (param: T, context: TestContext & ExtraContext) => MaybePromise<void>, timeout?: number) => void;
|
|
3398
|
+
}
|
|
3352
3399
|
|
|
3353
3400
|
export declare type TestInfo = TestCaseInfo | (TestSuiteInfo & {
|
|
3354
3401
|
tests: TestInfo[];
|
package/dist/worker.d.ts
CHANGED
|
@@ -2,6 +2,14 @@ import type { config } from 'chai';
|
|
|
2
2
|
import type { RsbuildConfig } from '@rsbuild/core';
|
|
3
3
|
import type { Writable } from 'node:stream';
|
|
4
4
|
|
|
5
|
+
declare type BlobReporterOptions = {
|
|
6
|
+
/**
|
|
7
|
+
* Directory to store blob report files.
|
|
8
|
+
* @default '.rstest-reports'
|
|
9
|
+
*/
|
|
10
|
+
outputDir?: string;
|
|
11
|
+
};
|
|
12
|
+
|
|
5
13
|
declare interface BranchMapping {
|
|
6
14
|
loc: Range_2;
|
|
7
15
|
type: string;
|
|
@@ -52,6 +60,13 @@ declare type BrowserModeConfig = {
|
|
|
52
60
|
* @default false
|
|
53
61
|
*/
|
|
54
62
|
strictPort?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Provider-specific config passed through to the selected browser provider.
|
|
65
|
+
*
|
|
66
|
+
* Use provider-owned types or helpers in user config when you want richer
|
|
67
|
+
* IntelliSense for this field.
|
|
68
|
+
*/
|
|
69
|
+
providerOptions?: Record<string, unknown>;
|
|
55
70
|
};
|
|
56
71
|
|
|
57
72
|
/**
|
|
@@ -68,7 +83,7 @@ declare type BrowserViewport = {
|
|
|
68
83
|
height: number;
|
|
69
84
|
} | DevicePreset;
|
|
70
85
|
|
|
71
|
-
declare type BuiltInReporterNames = 'default' | 'verbose' | 'md' | 'github-actions' | 'junit';
|
|
86
|
+
declare type BuiltInReporterNames = 'default' | 'verbose' | 'md' | 'github-actions' | 'junit' | 'blob';
|
|
72
87
|
|
|
73
88
|
declare type BuiltinReporterOptions = {
|
|
74
89
|
default: DefaultReporterOptions;
|
|
@@ -76,6 +91,7 @@ declare type BuiltinReporterOptions = {
|
|
|
76
91
|
md: MdReporterOptions;
|
|
77
92
|
'github-actions': Record<string, unknown>;
|
|
78
93
|
junit: Record<string, unknown>;
|
|
94
|
+
blob: BlobReporterOptions;
|
|
79
95
|
};
|
|
80
96
|
|
|
81
97
|
declare type ChaiConfig = Partial<Omit<typeof config, 'useProxy' | 'proxyExcludedKeys' | 'deepEqual'>>;
|
|
@@ -253,6 +269,12 @@ declare type CoverageOptions = {
|
|
|
253
269
|
* @default false
|
|
254
270
|
*/
|
|
255
271
|
reportOnFailure?: boolean;
|
|
272
|
+
/**
|
|
273
|
+
* Whether to collect coverage for source files outside the project root directory.
|
|
274
|
+
* This is useful in monorepo setups where tests import modules from sibling packages.
|
|
275
|
+
* @default false
|
|
276
|
+
*/
|
|
277
|
+
allowExternal?: boolean;
|
|
256
278
|
};
|
|
257
279
|
|
|
258
280
|
declare type CoverageThreshold = {
|
|
@@ -567,6 +589,7 @@ declare type NormalizedBrowserModeConfig = {
|
|
|
567
589
|
port?: number;
|
|
568
590
|
strictPort: boolean;
|
|
569
591
|
viewport?: BrowserViewport;
|
|
592
|
+
providerOptions: Record<string, unknown>;
|
|
570
593
|
};
|
|
571
594
|
|
|
572
595
|
declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool' | 'projects' | 'coverage' | 'setupFiles' | 'globalSetup' | 'exclude' | 'testEnvironment' | 'browser'>> & Partial<Pick<RstestConfig, OptionalKeys>> & {
|
|
@@ -766,13 +789,13 @@ declare type RoObject<T> = {
|
|
|
766
789
|
[K in keyof T]: T[K] | Ro<T[K]>;
|
|
767
790
|
};
|
|
768
791
|
|
|
769
|
-
declare type RstestCommand = 'watch' | 'run' | 'list';
|
|
792
|
+
declare type RstestCommand = 'watch' | 'run' | 'list' | 'merge-reports';
|
|
770
793
|
|
|
771
794
|
declare interface RstestConfig {
|
|
772
795
|
/**
|
|
773
796
|
* Extend configuration from adapters
|
|
774
797
|
*/
|
|
775
|
-
extends?: ExtendConfigFn | ExtendConfig;
|
|
798
|
+
extends?: ExtendConfigFn | ExtendConfig | (ExtendConfigFn | ExtendConfig)[];
|
|
776
799
|
/**
|
|
777
800
|
* Project root
|
|
778
801
|
*
|
|
@@ -1031,6 +1054,10 @@ declare type RstestContext = {
|
|
|
1031
1054
|
reporters: Reporter[];
|
|
1032
1055
|
snapshotManager: SnapshotManager;
|
|
1033
1056
|
stateManager: TestStateManager;
|
|
1057
|
+
reporterResults: {
|
|
1058
|
+
results: TestFileResult[];
|
|
1059
|
+
testResults: TestResult[];
|
|
1060
|
+
};
|
|
1034
1061
|
};
|
|
1035
1062
|
|
|
1036
1063
|
declare type RstestPoolOptions = {
|
package/dist/worker.js
CHANGED
|
@@ -3,7 +3,7 @@ import { __webpack_require__ } from "./rslib-runtime.js";
|
|
|
3
3
|
import { existsSync, promises } from "node:fs";
|
|
4
4
|
import "./1255.js";
|
|
5
5
|
import { createWorkerMetaMessage, createBirpc } from "./1983.js";
|
|
6
|
-
import { basename, isAbsolute, color, dirname, resolve as pathe_M_eThtNZ_resolve, join } from "./6830.js";
|
|
6
|
+
import { basename, isAbsolute, color as logger_color, dirname, resolve as pathe_M_eThtNZ_resolve, join } from "./6830.js";
|
|
7
7
|
import { createCoverageProvider } from "./7704.js";
|
|
8
8
|
import { formatTestError, setRealTimers, getRealTimers } from "./7552.js";
|
|
9
9
|
import { globalApis } from "./4411.js";
|
|
@@ -101,6 +101,25 @@ const registerGlobalApi = (api)=>globalApis.reduce((apis, key)=>{
|
|
|
101
101
|
}, {});
|
|
102
102
|
const globalCleanups = [];
|
|
103
103
|
let isTeardown = false;
|
|
104
|
+
const setErrorName = (error, type)=>{
|
|
105
|
+
try {
|
|
106
|
+
error.name = type;
|
|
107
|
+
return error;
|
|
108
|
+
} catch {
|
|
109
|
+
try {
|
|
110
|
+
Object.defineProperty(error, 'name', {
|
|
111
|
+
value: type,
|
|
112
|
+
configurable: true
|
|
113
|
+
});
|
|
114
|
+
return error;
|
|
115
|
+
} catch {
|
|
116
|
+
const fallbackError = new Error(error.message);
|
|
117
|
+
fallbackError.name = type;
|
|
118
|
+
fallbackError.stack = error.stack;
|
|
119
|
+
return fallbackError;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
};
|
|
104
123
|
const setupEnv = (env)=>{
|
|
105
124
|
if (env) Object.entries(env).forEach(([key, value])=>{
|
|
106
125
|
if (void 0 === value) delete process.env[key];
|
|
@@ -152,10 +171,10 @@ const preparePool = async ({ entryInfo: { distPath, testPath }, updateSnapshot,
|
|
|
152
171
|
const { createRstestRuntime } = await import("./1949.js");
|
|
153
172
|
const unhandledErrors = [];
|
|
154
173
|
const handleError = (e, type)=>{
|
|
155
|
-
const
|
|
156
|
-
error.name
|
|
174
|
+
const rawError = 'string' == typeof e ? new Error(e) : e;
|
|
175
|
+
const error = rawError.name && 'Error' !== rawError.name ? rawError : setErrorName(rawError, type);
|
|
157
176
|
if (isTeardown) {
|
|
158
|
-
error.stack = `${
|
|
177
|
+
error.stack = `${logger_color.yellow('Caught error after test environment was torn down:')}\n\n${error.stack}`;
|
|
159
178
|
console.error(error);
|
|
160
179
|
} else {
|
|
161
180
|
console.error(error);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rstest/core",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.4",
|
|
4
4
|
"description": "The Rsbuild-based test tool.",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/web-infra-dev/rstest/issues"
|
|
@@ -54,20 +54,20 @@
|
|
|
54
54
|
"importMeta.d.ts"
|
|
55
55
|
],
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@rsbuild/core": "2.0.0-beta.
|
|
57
|
+
"@rsbuild/core": "2.0.0-beta.9",
|
|
58
58
|
"@types/chai": "^5.2.3",
|
|
59
59
|
"tinypool": "^2.1.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@rsbuild/plugin-less": "^1.6.0",
|
|
63
|
-
"@rsbuild/plugin-sass": "^1.5.0",
|
|
64
62
|
"@babel/code-frame": "^7.29.0",
|
|
65
63
|
"@clack/prompts": "^1.1.0",
|
|
66
64
|
"@jridgewell/trace-mapping": "0.3.31",
|
|
67
|
-
"@microsoft/api-extractor": "^7.57.
|
|
65
|
+
"@microsoft/api-extractor": "^7.57.7",
|
|
66
|
+
"@rsbuild/plugin-less": "^1.6.2",
|
|
68
67
|
"@rsbuild/plugin-node-polyfill": "^1.4.4",
|
|
68
|
+
"@rsbuild/plugin-sass": "^1.5.1",
|
|
69
69
|
"@rslib/core": "0.20.0",
|
|
70
|
-
"@sinonjs/fake-timers": "^15.1.
|
|
70
|
+
"@sinonjs/fake-timers": "^15.1.1",
|
|
71
71
|
"@types/babel__code-frame": "^7.27.0",
|
|
72
72
|
"@types/istanbul-lib-coverage": "^2.0.6",
|
|
73
73
|
"@types/istanbul-lib-report": "^3.0.3",
|
|
@@ -76,36 +76,37 @@
|
|
|
76
76
|
"@types/picomatch": "^4.0.2",
|
|
77
77
|
"@types/sinonjs__fake-timers": "^8.1.5",
|
|
78
78
|
"@types/source-map-support": "^0.5.10",
|
|
79
|
+
"@typescript/native-preview": "7.0.0-dev.20260317.1",
|
|
79
80
|
"@vitest/expect": "^3.2.4",
|
|
80
81
|
"@vitest/snapshot": "^3.2.4",
|
|
81
82
|
"birpc": "^4.0.0",
|
|
82
83
|
"cac": "^7.0.0",
|
|
83
84
|
"chai": "^6.2.2",
|
|
84
|
-
"chokidar": "^
|
|
85
|
-
"happy-dom": "^20.
|
|
86
|
-
"jest-diff": "^30.
|
|
87
|
-
"jsdom": "^
|
|
88
|
-
"memfs": "^4.56.
|
|
85
|
+
"chokidar": "^5.0.0",
|
|
86
|
+
"happy-dom": "^20.8.4",
|
|
87
|
+
"jest-diff": "^30.3.0",
|
|
88
|
+
"jsdom": "^28.1.0",
|
|
89
|
+
"memfs": "^4.56.11",
|
|
89
90
|
"package-manager-detector": "^1.6.0",
|
|
90
91
|
"pathe": "^2.0.3",
|
|
91
92
|
"picocolors": "^1.1.1",
|
|
92
93
|
"picomatch": "^4.0.3",
|
|
93
|
-
"pretty-format": "^30.
|
|
94
|
-
"rslog": "^2.0.
|
|
94
|
+
"pretty-format": "^30.3.0",
|
|
95
|
+
"rslog": "^2.0.1",
|
|
95
96
|
"source-map-support": "^0.5.21",
|
|
96
97
|
"stacktrace-parser": "0.1.11",
|
|
97
98
|
"std-env": "^4.0.0",
|
|
98
|
-
"strip-ansi": "^7.
|
|
99
|
+
"strip-ansi": "^7.2.0",
|
|
99
100
|
"tinyglobby": "^0.2.15",
|
|
100
101
|
"tinyspy": "^4.0.4",
|
|
101
102
|
"url-extras": "^0.1.0",
|
|
103
|
+
"webpack": "^5.105.4",
|
|
102
104
|
"webpack-license-plugin": "^4.5.1",
|
|
103
|
-
"
|
|
104
|
-
"@rstest/tsconfig": "0.0.1"
|
|
105
|
-
"@rstest/browser-ui": "0.0.0"
|
|
105
|
+
"@rstest/browser-ui": "0.0.0",
|
|
106
|
+
"@rstest/tsconfig": "0.0.1"
|
|
106
107
|
},
|
|
107
108
|
"peerDependencies": {
|
|
108
|
-
"happy-dom": "
|
|
109
|
+
"happy-dom": "^20.8.3",
|
|
109
110
|
"jsdom": "*"
|
|
110
111
|
},
|
|
111
112
|
"peerDependenciesMeta": {
|
|
File without changes
|