@rstest/core 0.8.5 → 0.9.1

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.
@@ -546,7 +546,7 @@ declare type CoverageThresholds = CoverageThreshold | (CoverageThreshold & Thres
546
546
  export declare const createRstestRuntime: (workerState: WorkerState) => Promise<{
547
547
  runner: {
548
548
  runTests: (testPath: string, hooks: RunnerHooks, api: Rstest) => Promise<TestFileResult>;
549
- collectTests: () => Promise<Test[]>;
549
+ collectTests: () => Promise<TestInfo[]>;
550
550
  getCurrentTest: () => TestCase | undefined;
551
551
  };
552
552
  api: Rstest;
@@ -1427,6 +1427,13 @@ declare type MdReporterOptions = {
1427
1427
  * @default 'file+name'
1428
1428
  */
1429
1429
  reproduction?: boolean | 'file' | 'file+name';
1430
+ /**
1431
+ * Test lists (Passed / Skipped / Todo) display mode.
1432
+ * - `'auto'`: show only when all tests pass and the run is focused
1433
+ * - `'always'`: always show regardless of test status or focus
1434
+ * @default 'auto'
1435
+ */
1436
+ testLists?: 'auto' | 'always';
1430
1437
  /**
1431
1438
  * Failure output controls.
1432
1439
  * @default { max: 50 }
@@ -1750,7 +1757,7 @@ export declare const onTestFinished: Rstest['onTestFinished'];
1750
1757
 
1751
1758
  declare type OnTestFinishedHandler = (ctx: TestContext) => MaybePromise<void>;
1752
1759
 
1753
- declare type OptionalKeys = 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'output' | 'performance' | 'tools' | 'dev' | 'onConsoleLog' | 'chaiConfig' | 'hideSkippedTestFiles' | 'resolveSnapshotPath' | 'extends' | 'shard';
1760
+ declare type OptionalKeys = 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'output' | 'tools' | 'dev' | 'onConsoleLog' | 'chaiConfig' | 'hideSkippedTestFiles' | 'resolveSnapshotPath' | 'extends' | 'shard';
1754
1761
 
1755
1762
  declare interface Options {
1756
1763
  logger: {
@@ -2113,7 +2120,7 @@ declare interface RstestConfig {
2113
2120
  */
2114
2121
  unstubGlobals?: boolean;
2115
2122
  /**
2116
- * Restores all `process.env` values that were changed with `rstest.stubEnv` before every test.
2123
+ * Restores all runtime env values that were changed with `rstest.stubEnv` before every test.
2117
2124
  * @default false
2118
2125
  */
2119
2126
  unstubEnvs?: boolean;
@@ -2159,7 +2166,6 @@ declare interface RstestConfig {
2159
2166
  includeTaskLocation?: boolean;
2160
2167
  plugins?: RsbuildConfig['plugins'];
2161
2168
  source?: Pick<NonNullable<RsbuildConfig['source']>, 'define' | 'tsconfigPath' | 'decorators' | 'include' | 'exclude'>;
2162
- performance?: Pick<NonNullable<RsbuildConfig['performance']>, 'bundleAnalyze'>;
2163
2169
  dev?: Pick<NonNullable<RsbuildConfig['dev']>, 'writeToDisk'>;
2164
2170
  output?: Pick<NonNullable<RsbuildConfig['output']>, 'cssModules' | 'externals' | 'cleanDistPath' | 'module'>;
2165
2171
  resolve?: RsbuildConfig['resolve'];
@@ -2380,11 +2386,12 @@ declare interface RstestUtilities {
2380
2386
  */
2381
2387
  resetModules: () => RstestUtilities;
2382
2388
  /**
2383
- * Changes the value of environmental variable on `process.env`.
2389
+ * Changes the value of an environment variable in the current runtime env store.
2390
+ * Uses `process.env` in Node.js and runtime env store in browser mode.
2384
2391
  */
2385
2392
  stubEnv: (name: string, value: string | undefined) => RstestUtilities;
2386
2393
  /**
2387
- * Restores all `process.env` values that were changed with `rstest.stubEnv`.
2394
+ * Restores all env values that were changed with `rstest.stubEnv`.
2388
2395
  */
2389
2396
  unstubAllEnvs: () => RstestUtilities;
2390
2397
  /**
@@ -2436,6 +2443,17 @@ declare interface RstestUtilities {
2436
2443
  * Removes all timers that are scheduled to run.
2437
2444
  */
2438
2445
  clearAllTimers: () => RstestUtilities;
2446
+ /**
2447
+ * Retry callback until it succeeds (doesn't throw) or timeout is reached.
2448
+ * If timeout is reached, throws the last error from the callback.
2449
+ */
2450
+ waitFor: <T>(callback: WaitForCallback<T>, options?: number | WaitForOptions) => Promise<T>;
2451
+ /**
2452
+ * Retry callback until it returns a truthy value or timeout is reached.
2453
+ * If callback throws, it interrupts immediately and throws that error.
2454
+ * If timeout is reached, throws an error.
2455
+ */
2456
+ waitUntil: <T>(callback: () => MaybePromise<T>, options?: number | WaitUntilOptions) => Promise<T>;
2439
2457
  }
2440
2458
 
2441
2459
  declare type RunnerAPI = {
@@ -2735,7 +2753,6 @@ declare type TestCallbackFn<ExtraContext = object> = (context: TestContext & Ext
2735
2753
  declare type TestCase = TestCaseInfo & {
2736
2754
  originalFn?: (context: TestContext) => void | Promise<void>;
2737
2755
  fn?: (context: TestContext) => void | Promise<void>;
2738
- runMode: TestRunMode;
2739
2756
  fails?: boolean;
2740
2757
  each?: boolean;
2741
2758
  fixtures?: NormalizedFixtures;
@@ -2771,6 +2788,7 @@ declare type TestCaseInfo = {
2771
2788
  /** Only included when `includeTaskLocation` config is enabled */
2772
2789
  location?: Location_2;
2773
2790
  type: 'case';
2791
+ runMode: TestRunMode;
2774
2792
  };
2775
2793
 
2776
2794
  declare type TestContext = {
@@ -2808,14 +2826,14 @@ declare type TestFileInfo = {
2808
2826
  export declare type TestFileResult = TestResult & {
2809
2827
  results: TestResult[];
2810
2828
  snapshotResult?: SnapshotResult;
2811
- coverage?: CoverageMapData;
2829
+ coverage?: Record<string, FileCoverageData>;
2812
2830
  };
2813
2831
 
2814
2832
  declare type TestFn<ExtraContext = object> = (description: string, fn?: TestCallbackFn<ExtraContext>, timeout?: number) => void;
2815
2833
 
2816
2834
  declare type TestForFn<ExtraContext = object> = <T>(cases: readonly T[]) => (description: string, fn?: (param: T, context: TestContext & ExtraContext) => MaybePromise<void>, timeout?: number) => void;
2817
2835
 
2818
- declare type TestInfo = TestCaseInfo | (TestSuiteInfo & {
2836
+ export declare type TestInfo = TestCaseInfo | (TestSuiteInfo & {
2819
2837
  tests: TestInfo[];
2820
2838
  });
2821
2839
 
@@ -2857,7 +2875,6 @@ declare class TestStateManager {
2857
2875
  }
2858
2876
 
2859
2877
  declare type TestSuite = TestSuiteInfo & {
2860
- runMode: TestRunMode;
2861
2878
  each?: boolean;
2862
2879
  inTestEach?: boolean;
2863
2880
  concurrent?: boolean;
@@ -2879,6 +2896,7 @@ declare type TestSuiteInfo = {
2879
2896
  type: 'suite';
2880
2897
  /** Only included when `includeTaskLocation` config is enabled */
2881
2898
  location?: Location_2;
2899
+ runMode: TestRunMode;
2882
2900
  };
2883
2901
 
2884
2902
  declare type TextLcovOptions = ProjectOptions;
@@ -2959,6 +2977,18 @@ declare type VitestAssertion<
2959
2977
  T
2960
2978
  > = { [K in keyof A] : A[K] extends Chai.Assertion ? Assertion_2<T> : A[K] extends (...args: any[]) => any ? A[K] : VitestAssertion<A[K], T> } & ((type: string, message?: string) => Assertion_2);
2961
2979
 
2980
+ declare type WaitForCallback<T> = () => MaybePromise<T>;
2981
+
2982
+ declare interface WaitForOptions {
2983
+ timeout?: number;
2984
+ interval?: number;
2985
+ }
2986
+
2987
+ declare interface WaitUntilOptions {
2988
+ timeout?: number;
2989
+ interval?: number;
2990
+ }
2991
+
2962
2992
  declare type Watermark = [number, number];
2963
2993
 
2964
2994
  declare interface Watermarks {
package/dist/browser.d.ts CHANGED
@@ -338,6 +338,11 @@ declare type BrowserModeConfig = {
338
338
  */
339
339
  declare type BrowserName = 'chromium' | 'firefox' | 'webkit';
340
340
 
341
+ declare interface BrowserSourcemapResolutionResult {
342
+ handled: boolean;
343
+ sourcemap: SourceMapInput | null;
344
+ }
345
+
341
346
  /**
342
347
  * Options for running browser tests.
343
348
  */
@@ -375,6 +380,12 @@ export declare interface BrowserTestRunResult {
375
380
  hasFailure: boolean;
376
381
  /** Errors that occurred before/outside test execution (e.g., browser launch failure) */
377
382
  unhandledErrors?: Error[];
383
+ /** Source map resolver used when reporter output is unified in core */
384
+ getSourcemap?: GetSourcemap;
385
+ /** Route-aware source map resolver used by core unified reporter flow */
386
+ resolveSourcemap?: ResolveBrowserSourcemap;
387
+ /** Deferred cleanup hook for unified reporter mode */
388
+ close?: () => Promise<void>;
378
389
  }
379
390
 
380
391
  declare type BrowserViewport = {
@@ -681,7 +692,7 @@ declare type CoverageThresholds = CoverageThreshold | (CoverageThreshold & Thres
681
692
  export declare const createRstestRuntime: (workerState: WorkerState) => Promise<{
682
693
  runner: {
683
694
  runTests: (testPath: string, hooks: RunnerHooks, api: Rstest_2) => Promise<TestFileResult>;
684
- collectTests: () => Promise<Test[]>;
695
+ collectTests: () => Promise<TestInfo[]>;
685
696
  getCurrentTest: () => TestCase | undefined;
686
697
  };
687
698
  api: Rstest_2;
@@ -1527,7 +1538,7 @@ declare interface LinkMapper {
1527
1538
  }
1528
1539
 
1529
1540
  export declare type ListCommandResult = {
1530
- tests: Test[];
1541
+ tests: TestInfo[];
1531
1542
  testPath: string;
1532
1543
  project: string;
1533
1544
  errors?: FormattedError[];
@@ -1642,6 +1653,13 @@ declare type MdReporterOptions = {
1642
1653
  * @default 'file+name'
1643
1654
  */
1644
1655
  reproduction?: boolean | 'file' | 'file+name';
1656
+ /**
1657
+ * Test lists (Passed / Skipped / Todo) display mode.
1658
+ * - `'auto'`: show only when all tests pass and the run is focused
1659
+ * - `'always'`: always show regardless of test status or focus
1660
+ * @default 'auto'
1661
+ */
1662
+ testLists?: 'auto' | 'always';
1645
1663
  /**
1646
1664
  * Failure output controls.
1647
1665
  * @default { max: 50 }
@@ -2274,7 +2292,7 @@ export declare const onTestFinished: Rstest_2['onTestFinished'];
2274
2292
 
2275
2293
  declare type OnTestFinishedHandler = (ctx: TestContext) => MaybePromise<void>;
2276
2294
 
2277
- declare type OptionalKeys = 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'output' | 'performance' | 'tools' | 'dev' | 'onConsoleLog' | 'chaiConfig' | 'hideSkippedTestFiles' | 'resolveSnapshotPath' | 'extends' | 'shard';
2295
+ declare type OptionalKeys = 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'output' | 'tools' | 'dev' | 'onConsoleLog' | 'chaiConfig' | 'hideSkippedTestFiles' | 'resolveSnapshotPath' | 'extends' | 'shard';
2278
2296
 
2279
2297
  declare interface Options {
2280
2298
  logger: {
@@ -2487,6 +2505,8 @@ declare interface ReportOptions {
2487
2505
 
2488
2506
  declare type ReportWithOptions<Name extends keyof ReportOptions = keyof ReportOptions> = Name extends keyof ReportOptions ? [Name, Partial<ReportOptions[Name]>] : [Name, Record<string, unknown>];
2489
2507
 
2508
+ declare type ResolveBrowserSourcemap = (sourcePath: string) => Promise<BrowserSourcemapResolutionResult>;
2509
+
2490
2510
  declare type Ro<T> = T extends Array<infer V> ? V[] | Readonly<V[]> | RoArray<V> | Readonly<RoArray<V>> : T extends object ? T | Readonly<T> | RoObject<T> | Readonly<RoObject<T>> : T;
2491
2511
 
2492
2512
  declare type RoArray<T> = Ro<T>[];
@@ -2711,7 +2731,7 @@ declare interface RstestConfig {
2711
2731
  */
2712
2732
  unstubGlobals?: boolean;
2713
2733
  /**
2714
- * Restores all `process.env` values that were changed with `rstest.stubEnv` before every test.
2734
+ * Restores all runtime env values that were changed with `rstest.stubEnv` before every test.
2715
2735
  * @default false
2716
2736
  */
2717
2737
  unstubEnvs?: boolean;
@@ -2757,7 +2777,6 @@ declare interface RstestConfig {
2757
2777
  includeTaskLocation?: boolean;
2758
2778
  plugins?: RsbuildConfig['plugins'];
2759
2779
  source?: Pick<NonNullable<RsbuildConfig['source']>, 'define' | 'tsconfigPath' | 'decorators' | 'include' | 'exclude'>;
2760
- performance?: Pick<NonNullable<RsbuildConfig['performance']>, 'bundleAnalyze'>;
2761
2780
  dev?: Pick<NonNullable<RsbuildConfig['dev']>, 'writeToDisk'>;
2762
2781
  output?: Pick<NonNullable<RsbuildConfig['output']>, 'cssModules' | 'externals' | 'cleanDistPath' | 'module'>;
2763
2782
  resolve?: RsbuildConfig['resolve'];
@@ -2978,11 +2997,12 @@ declare interface RstestUtilities {
2978
2997
  */
2979
2998
  resetModules: () => RstestUtilities;
2980
2999
  /**
2981
- * Changes the value of environmental variable on `process.env`.
3000
+ * Changes the value of an environment variable in the current runtime env store.
3001
+ * Uses `process.env` in Node.js and runtime env store in browser mode.
2982
3002
  */
2983
3003
  stubEnv: (name: string, value: string | undefined) => RstestUtilities;
2984
3004
  /**
2985
- * Restores all `process.env` values that were changed with `rstest.stubEnv`.
3005
+ * Restores all env values that were changed with `rstest.stubEnv`.
2986
3006
  */
2987
3007
  unstubAllEnvs: () => RstestUtilities;
2988
3008
  /**
@@ -3034,6 +3054,17 @@ declare interface RstestUtilities {
3034
3054
  * Removes all timers that are scheduled to run.
3035
3055
  */
3036
3056
  clearAllTimers: () => RstestUtilities;
3057
+ /**
3058
+ * Retry callback until it succeeds (doesn't throw) or timeout is reached.
3059
+ * If timeout is reached, throws the last error from the callback.
3060
+ */
3061
+ waitFor: <T>(callback: WaitForCallback<T>, options?: number | WaitForOptions) => Promise<T>;
3062
+ /**
3063
+ * Retry callback until it returns a truthy value or timeout is reached.
3064
+ * If callback throws, it interrupts immediately and throws that error.
3065
+ * If timeout is reached, throws an error.
3066
+ */
3067
+ waitUntil: <T>(callback: () => MaybePromise<T>, options?: number | WaitUntilOptions) => Promise<T>;
3037
3068
  }
3038
3069
 
3039
3070
  declare type RunnerAPI = {
@@ -3349,7 +3380,6 @@ declare type TestCallbackFn<ExtraContext = object> = (context: TestContext & Ext
3349
3380
  declare type TestCase = TestCaseInfo & {
3350
3381
  originalFn?: (context: TestContext) => void | Promise<void>;
3351
3382
  fn?: (context: TestContext) => void | Promise<void>;
3352
- runMode: TestRunMode;
3353
3383
  fails?: boolean;
3354
3384
  each?: boolean;
3355
3385
  fixtures?: NormalizedFixtures;
@@ -3385,6 +3415,7 @@ declare type TestCaseInfo = {
3385
3415
  /** Only included when `includeTaskLocation` config is enabled */
3386
3416
  location?: Location_2;
3387
3417
  type: 'case';
3418
+ runMode: TestRunMode;
3388
3419
  };
3389
3420
 
3390
3421
  declare type TestContext = {
@@ -3422,7 +3453,7 @@ declare type TestFileInfo = {
3422
3453
  export declare type TestFileResult = TestResult & {
3423
3454
  results: TestResult[];
3424
3455
  snapshotResult?: SnapshotResult;
3425
- coverage?: CoverageMapData;
3456
+ coverage?: Record<string, FileCoverageData>;
3426
3457
  };
3427
3458
 
3428
3459
  declare type TestFn<ExtraContext = object> = (description: string, fn?: TestCallbackFn<ExtraContext>, timeout?: number) => void;
@@ -3471,7 +3502,6 @@ declare class TestStateManager {
3471
3502
  }
3472
3503
 
3473
3504
  declare type TestSuite = TestSuiteInfo & {
3474
- runMode: TestRunMode;
3475
3505
  each?: boolean;
3476
3506
  inTestEach?: boolean;
3477
3507
  concurrent?: boolean;
@@ -3493,6 +3523,7 @@ declare type TestSuiteInfo = {
3493
3523
  type: 'suite';
3494
3524
  /** Only included when `includeTaskLocation` config is enabled */
3495
3525
  location?: Location_2;
3526
+ runMode: TestRunMode;
3496
3527
  };
3497
3528
 
3498
3529
  declare type TextLcovOptions = ProjectOptions;
@@ -3573,6 +3604,18 @@ declare type VitestAssertion<
3573
3604
  T
3574
3605
  > = { [K in keyof A] : A[K] extends Chai.Assertion ? Assertion_2<T> : A[K] extends (...args: any[]) => any ? A[K] : VitestAssertion<A[K], T> } & ((type: string, message?: string) => Assertion_2);
3575
3606
 
3607
+ declare type WaitForCallback<T> = () => MaybePromise<T>;
3608
+
3609
+ declare interface WaitForOptions {
3610
+ timeout?: number;
3611
+ interval?: number;
3612
+ }
3613
+
3614
+ declare interface WaitUntilOptions {
3615
+ timeout?: number;
3616
+ interval?: number;
3617
+ }
3618
+
3576
3619
  declare type Watermark = [number, number];
3577
3620
 
3578
3621
  declare interface Watermarks {
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ import type { config } from 'chai';
3
3
  import { LoadConfigOptions } from '@rsbuild/core';
4
4
  import type { RsbuildConfig } from '@rsbuild/core';
5
5
  import type { RsbuildPlugin } from '@rsbuild/core';
6
+ import { Rspack } from '@rsbuild/core';
6
7
  import type { Writable } from 'node:stream';
7
8
 
8
9
  /**
@@ -885,7 +886,7 @@ declare interface ExpectPollOptions {
885
886
  message?: string;
886
887
  }
887
888
 
888
- declare interface ExpectStatic extends ExpectStatic_2 {
889
+ export declare interface ExpectStatic extends ExpectStatic_2 {
889
890
  <T>(actual: T, message?: string): Assertion<T>;
890
891
  unreachable: (message?: string) => never;
891
892
  soft: <T>(actual: T, message?: string) => Assertion<T>;
@@ -1536,7 +1537,7 @@ declare type ListCommandOptions = {
1536
1537
  };
1537
1538
 
1538
1539
  declare type ListCommandResult = {
1539
- tests: Test_2[];
1540
+ tests: TestInfo[];
1540
1541
  testPath: string;
1541
1542
  project: string;
1542
1543
  errors?: FormattedError[];
@@ -1652,6 +1653,13 @@ declare type MdReporterOptions = {
1652
1653
  * @default 'file+name'
1653
1654
  */
1654
1655
  reproduction?: boolean | 'file' | 'file+name';
1656
+ /**
1657
+ * Test lists (Passed / Skipped / Todo) display mode.
1658
+ * - `'auto'`: show only when all tests pass and the run is focused
1659
+ * - `'always'`: always show regardless of test status or focus
1660
+ * @default 'auto'
1661
+ */
1662
+ testLists?: 'auto' | 'always';
1655
1663
  /**
1656
1664
  * Failure output controls.
1657
1665
  * @default { max: 50 }
@@ -2261,15 +2269,6 @@ export declare type NormalizedCoverageOptions = Required<Omit<CoverageOptions, '
2261
2269
  include?: string[];
2262
2270
  };
2263
2271
 
2264
- declare type NormalizedFixture = {
2265
- isFn: boolean;
2266
- deps?: string[];
2267
- value: FixtureFn<any, any, any> | any;
2268
- options?: FixtureOptions;
2269
- };
2270
-
2271
- declare type NormalizedFixtures = Record<string, NormalizedFixture>;
2272
-
2273
2272
  declare type NormalizedProcedure<T extends Procedure> = (...args: Parameters<T>) => ReturnType<T>;
2274
2273
 
2275
2274
  declare type NormalizedProcedure_2<T extends Procedure_2> = (...args: Parameters<T>) => ReturnType<T>;
@@ -2292,7 +2291,7 @@ export declare const onTestFinished: Rstest['onTestFinished'];
2292
2291
 
2293
2292
  declare type OnTestFinishedHandler = (ctx: TestContext) => MaybePromise<void>;
2294
2293
 
2295
- declare type OptionalKeys = 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'output' | 'performance' | 'tools' | 'dev' | 'onConsoleLog' | 'chaiConfig' | 'hideSkippedTestFiles' | 'resolveSnapshotPath' | 'extends' | 'shard';
2294
+ declare type OptionalKeys = 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'output' | 'tools' | 'dev' | 'onConsoleLog' | 'chaiConfig' | 'hideSkippedTestFiles' | 'resolveSnapshotPath' | 'extends' | 'shard';
2296
2295
 
2297
2296
  declare interface Options {
2298
2297
  logger: {
@@ -2513,6 +2512,8 @@ export declare const rs: RstestUtilities;
2513
2512
 
2514
2513
  export { RsbuildPlugin }
2515
2514
 
2515
+ export { Rspack }
2516
+
2516
2517
  export declare type Rstest = RunnerAPI & {
2517
2518
  expect: Expect;
2518
2519
  assert: typeof assert_2;
@@ -2703,7 +2704,7 @@ export declare interface RstestConfig {
2703
2704
  */
2704
2705
  unstubGlobals?: boolean;
2705
2706
  /**
2706
- * Restores all `process.env` values that were changed with `rstest.stubEnv` before every test.
2707
+ * Restores all runtime env values that were changed with `rstest.stubEnv` before every test.
2707
2708
  * @default false
2708
2709
  */
2709
2710
  unstubEnvs?: boolean;
@@ -2749,7 +2750,6 @@ export declare interface RstestConfig {
2749
2750
  includeTaskLocation?: boolean;
2750
2751
  plugins?: RsbuildConfig['plugins'];
2751
2752
  source?: Pick<NonNullable<RsbuildConfig['source']>, 'define' | 'tsconfigPath' | 'decorators' | 'include' | 'exclude'>;
2752
- performance?: Pick<NonNullable<RsbuildConfig['performance']>, 'bundleAnalyze'>;
2753
2753
  dev?: Pick<NonNullable<RsbuildConfig['dev']>, 'writeToDisk'>;
2754
2754
  output?: Pick<NonNullable<RsbuildConfig['output']>, 'cssModules' | 'externals' | 'cleanDistPath' | 'module'>;
2755
2755
  resolve?: RsbuildConfig['resolve'];
@@ -2980,11 +2980,12 @@ export declare interface RstestUtilities {
2980
2980
  */
2981
2981
  resetModules: () => RstestUtilities;
2982
2982
  /**
2983
- * Changes the value of environmental variable on `process.env`.
2983
+ * Changes the value of an environment variable in the current runtime env store.
2984
+ * Uses `process.env` in Node.js and runtime env store in browser mode.
2984
2985
  */
2985
2986
  stubEnv: (name: string, value: string | undefined) => RstestUtilities;
2986
2987
  /**
2987
- * Restores all `process.env` values that were changed with `rstest.stubEnv`.
2988
+ * Restores all env values that were changed with `rstest.stubEnv`.
2988
2989
  */
2989
2990
  unstubAllEnvs: () => RstestUtilities;
2990
2991
  /**
@@ -3036,9 +3037,20 @@ export declare interface RstestUtilities {
3036
3037
  * Removes all timers that are scheduled to run.
3037
3038
  */
3038
3039
  clearAllTimers: () => RstestUtilities;
3040
+ /**
3041
+ * Retry callback until it succeeds (doesn't throw) or timeout is reached.
3042
+ * If timeout is reached, throws the last error from the callback.
3043
+ */
3044
+ waitFor: <T>(callback: WaitForCallback<T>, options?: number | WaitForOptions) => Promise<T>;
3045
+ /**
3046
+ * Retry callback until it returns a truthy value or timeout is reached.
3047
+ * If callback throws, it interrupts immediately and throws that error.
3048
+ * If timeout is reached, throws an error.
3049
+ */
3050
+ waitUntil: <T>(callback: () => MaybePromise<T>, options?: number | WaitUntilOptions) => Promise<T>;
3039
3051
  }
3040
3052
 
3041
- export declare function runCLI(): Promise<void>;
3053
+ export declare function runCLI(): void;
3042
3054
 
3043
3055
  declare type RunnerAPI = {
3044
3056
  describe: Describe;
@@ -3253,23 +3265,6 @@ declare interface SyncExpectationResult {
3253
3265
  expected?: any;
3254
3266
  }
3255
3267
 
3256
- declare interface TaskResult {
3257
- /**
3258
- * State of the task. Inherits the `task.mode` during collection.
3259
- * When the task has finished, it will be changed to `pass` or `fail`.
3260
- * - **pass**: task ran successfully
3261
- * - **fail**: task failed
3262
- */
3263
- state: TaskState;
3264
- /**
3265
- * Errors that occurred during the task execution. It is possible to have several errors
3266
- * if `expect.soft()` failed multiple times or `retry` was triggered.
3267
- */
3268
- errors?: FormattedError[];
3269
- }
3270
-
3271
- declare type TaskState = 'pass' | 'fail';
3272
-
3273
3268
  declare interface TeamcityOptions extends FileOptions {
3274
3269
  blockName: string;
3275
3270
  }
@@ -3278,8 +3273,6 @@ declare type Test = (arg0: any) => boolean;
3278
3273
 
3279
3274
  export declare const test: Rstest['test'];
3280
3275
 
3281
- declare type Test_2 = TestSuite | TestCase;
3282
-
3283
3276
  declare type TestAPI<ExtraContext = object> = TestFn<ExtraContext> & {
3284
3277
  each: TestEachFn;
3285
3278
  for: TestForFn<ExtraContext>;
@@ -3301,34 +3294,6 @@ declare type TestAPIs<ExtraContext = object> = TestAPI<ExtraContext> & {
3301
3294
 
3302
3295
  declare type TestCallbackFn<ExtraContext = object> = (context: TestContext & ExtraContext) => MaybePromise<void>;
3303
3296
 
3304
- declare type TestCase = TestCaseInfo & {
3305
- originalFn?: (context: TestContext) => void | Promise<void>;
3306
- fn?: (context: TestContext) => void | Promise<void>;
3307
- runMode: TestRunMode;
3308
- fails?: boolean;
3309
- each?: boolean;
3310
- fixtures?: NormalizedFixtures;
3311
- concurrent?: boolean;
3312
- sequential?: boolean;
3313
- inTestEach?: boolean;
3314
- context: TestContext;
3315
- only?: boolean;
3316
- onFinished: OnTestFinishedHandler[];
3317
- onFailed: OnTestFailedHandler[];
3318
- /**
3319
- * Store promises (from async expects) to wait for them before finishing the test
3320
- */
3321
- promises?: Promise<any>[];
3322
- /**
3323
- * Store stack trace error created when test is registered, used for trace original position
3324
- */
3325
- stackTraceError: Error;
3326
- /**
3327
- * Result of the task. if `expect.soft()` failed multiple times or `retry` was triggered.
3328
- */
3329
- result?: TaskResult;
3330
- };
3331
-
3332
3297
  export declare type TestCaseInfo = {
3333
3298
  testId: string;
3334
3299
  testPath: TestPath;
@@ -3340,6 +3305,7 @@ export declare type TestCaseInfo = {
3340
3305
  /** Only included when `includeTaskLocation` config is enabled */
3341
3306
  location?: Location_2;
3342
3307
  type: 'case';
3308
+ runMode: TestRunMode;
3343
3309
  };
3344
3310
 
3345
3311
  declare type TestContext = {
@@ -3377,7 +3343,7 @@ export declare type TestFileInfo = {
3377
3343
  export declare type TestFileResult = TestResult & {
3378
3344
  results: TestResult[];
3379
3345
  snapshotResult?: SnapshotResult;
3380
- coverage?: CoverageMapData;
3346
+ coverage?: Record<string, FileCoverageData>;
3381
3347
  };
3382
3348
 
3383
3349
  declare type TestFn<ExtraContext = object> = (description: string, fn?: TestCallbackFn<ExtraContext>, timeout?: number) => void;
@@ -3425,20 +3391,6 @@ declare class TestStateManager {
3425
3391
  reset(): void;
3426
3392
  }
3427
3393
 
3428
- declare type TestSuite = TestSuiteInfo & {
3429
- runMode: TestRunMode;
3430
- each?: boolean;
3431
- inTestEach?: boolean;
3432
- concurrent?: boolean;
3433
- sequential?: boolean;
3434
- /** nested cases and suite could in a suite */
3435
- tests: Test_2[];
3436
- afterAllListeners?: AfterAllListener[];
3437
- beforeAllListeners?: BeforeAllListener[];
3438
- afterEachListeners?: AfterEachListener[];
3439
- beforeEachListeners?: BeforeEachListener[];
3440
- };
3441
-
3442
3394
  export declare type TestSuiteInfo = {
3443
3395
  testId: string;
3444
3396
  name: string;
@@ -3448,6 +3400,7 @@ export declare type TestSuiteInfo = {
3448
3400
  type: 'suite';
3449
3401
  /** Only included when `includeTaskLocation` config is enabled */
3450
3402
  location?: Location_2;
3403
+ runMode: TestRunMode;
3451
3404
  };
3452
3405
 
3453
3406
  declare type TextLcovOptions = ProjectOptions;
@@ -3528,6 +3481,18 @@ declare type VitestAssertion<
3528
3481
  T
3529
3482
  > = { [K in keyof A] : A[K] extends Chai.Assertion ? Assertion_2<T> : A[K] extends (...args: any[]) => any ? A[K] : VitestAssertion<A[K], T> } & ((type: string, message?: string) => Assertion_2);
3530
3483
 
3484
+ declare type WaitForCallback<T> = () => MaybePromise<T>;
3485
+
3486
+ declare interface WaitForOptions {
3487
+ timeout?: number;
3488
+ interval?: number;
3489
+ }
3490
+
3491
+ declare interface WaitUntilOptions {
3492
+ timeout?: number;
3493
+ interval?: number;
3494
+ }
3495
+
3531
3496
  declare type Watermark = [number, number];
3532
3497
 
3533
3498
  declare interface Watermarks {
@@ -20,6 +20,8 @@ __webpack_require__ = new Proxy(function(...args) {
20
20
  });
21
21
  __webpack_require__.rstest_original_modules = {};
22
22
  __webpack_require__.rstest_original_module_factories = {};
23
+ const hasOwn = (target, property)=>Object.hasOwn(target, property);
24
+ const isPromise = (value)=>value instanceof Promise;
23
25
  __webpack_require__.rstest_unmock = (id)=>{
24
26
  const originalModuleFactory = __webpack_require__.rstest_original_module_factories[id];
25
27
  if (originalModuleFactory) __webpack_modules__[id] = originalModuleFactory;
@@ -27,9 +29,8 @@ __webpack_require__.rstest_unmock = (id)=>{
27
29
  };
28
30
  __webpack_require__.rstest_do_unmock = __webpack_require__.rstest_unmock;
29
31
  __webpack_require__.rstest_require_actual = __webpack_require__.rstest_import_actual = (id)=>{
30
- const originalModule = __webpack_require__.rstest_original_modules[id];
31
- if (originalModule) return originalModule;
32
- if (id in __webpack_require__.rstest_original_module_factories) {
32
+ if (hasOwn(__webpack_require__.rstest_original_modules, id)) return __webpack_require__.rstest_original_modules[id];
33
+ if (hasOwn(__webpack_require__.rstest_original_module_factories, id)) {
33
34
  const mod = __webpack_require__.rstest_original_module_factories[id];
34
35
  const moduleInstance = {
35
36
  exports: {}
@@ -43,12 +44,13 @@ __webpack_require__.rstest_require_actual = __webpack_require__.rstest_import_ac
43
44
  const getMockImplementation = (mockType = 'mock')=>{
44
45
  const isMockRequire = 'mockRequire' === mockType || 'doMockRequire' === mockType;
45
46
  return (id, modFactory)=>{
46
- let requiredModule = __webpack_module_cache__[id]?.exports;
47
- const wasAlreadyLoaded = !!requiredModule;
48
- if (requiredModule) {
49
- __webpack_require__.rstest_original_modules[id] = requiredModule;
50
- __webpack_require__.rstest_original_module_factories[id] = __webpack_modules__[id];
51
- } else __webpack_require__.rstest_original_module_factories[id] = __webpack_modules__[id];
47
+ const hasCachedModule = hasOwn(__webpack_module_cache__, id);
48
+ let requiredModule = hasCachedModule ? __webpack_module_cache__[id].exports : void 0;
49
+ const wasAlreadyLoaded = hasCachedModule;
50
+ const hasSavedOriginalModule = hasOwn(__webpack_require__.rstest_original_modules, id);
51
+ const hasSavedOriginalFactory = hasOwn(__webpack_require__.rstest_original_module_factories, id);
52
+ if (!hasSavedOriginalModule && hasCachedModule) __webpack_require__.rstest_original_modules[id] = requiredModule;
53
+ if (!hasSavedOriginalFactory) __webpack_require__.rstest_original_module_factories[id] = __webpack_modules__[id];
52
54
  if (modFactory && 'object' == typeof modFactory) {
53
55
  const isSpy = true === modFactory.spy;
54
56
  const isMock = true === modFactory.mock;
@@ -91,6 +93,10 @@ const getMockImplementation = (mockType = 'mock')=>{
91
93
  else if ('function' == typeof modFactory) {
92
94
  const finalModFactory = function(__webpack_module__, __webpack_exports__, __webpack_require__1) {
93
95
  const res = modFactory();
96
+ if (isPromise(res)) {
97
+ __webpack_module__.exports = res;
98
+ return;
99
+ }
94
100
  if (isMockRequire) {
95
101
  __webpack_module__.exports = res;
96
102
  return;