@rstest/core 0.8.4 → 0.9.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.
@@ -6360,7 +6360,7 @@ __webpack_require__.add({
6360
6360
  module.exports = fn;
6361
6361
  },
6362
6362
  "../../node_modules/.pnpm/is-typed-array@1.1.15/node_modules/is-typed-array/index.js" (module, __unused_rspack_exports, __webpack_require__) {
6363
- var whichTypedArray = __webpack_require__("../../node_modules/.pnpm/which-typed-array@1.1.19/node_modules/which-typed-array/index.js");
6363
+ var whichTypedArray = __webpack_require__("../../node_modules/.pnpm/which-typed-array@1.1.20/node_modules/which-typed-array/index.js");
6364
6364
  module.exports = function isTypedArray(value) {
6365
6365
  return !!whichTypedArray(value);
6366
6366
  };
@@ -8885,7 +8885,7 @@ __webpack_require__.add({
8885
8885
  "../../node_modules/.pnpm/util@0.12.5/node_modules/util/support/types.js" (__unused_rspack_module, exports, __webpack_require__) {
8886
8886
  var isArgumentsObject = __webpack_require__("../../node_modules/.pnpm/is-arguments@1.2.0/node_modules/is-arguments/index.js");
8887
8887
  var isGeneratorFunction = __webpack_require__("../../node_modules/.pnpm/is-generator-function@1.1.2/node_modules/is-generator-function/index.js");
8888
- var whichTypedArray = __webpack_require__("../../node_modules/.pnpm/which-typed-array@1.1.19/node_modules/which-typed-array/index.js");
8888
+ var whichTypedArray = __webpack_require__("../../node_modules/.pnpm/which-typed-array@1.1.20/node_modules/which-typed-array/index.js");
8889
8889
  var isTypedArray = __webpack_require__("../../node_modules/.pnpm/is-typed-array@1.1.15/node_modules/is-typed-array/index.js");
8890
8890
  function uncurryThis(f) {
8891
8891
  return f.call.bind(f);
@@ -9551,7 +9551,7 @@ __webpack_require__.add({
9551
9551
  }
9552
9552
  exports.callbackify = callbackify;
9553
9553
  },
9554
- "../../node_modules/.pnpm/which-typed-array@1.1.19/node_modules/which-typed-array/index.js" (module, __unused_rspack_exports, __webpack_require__) {
9554
+ "../../node_modules/.pnpm/which-typed-array@1.1.20/node_modules/which-typed-array/index.js" (module, __unused_rspack_exports, __webpack_require__) {
9555
9555
  var forEach = __webpack_require__("../../node_modules/.pnpm/for-each@0.3.5/node_modules/for-each/index.js");
9556
9556
  var availableTypedArrays = __webpack_require__("../../node_modules/.pnpm/available-typed-arrays@1.0.7/node_modules/available-typed-arrays/index.js");
9557
9557
  var callBind = __webpack_require__("../../node_modules/.pnpm/call-bind@1.0.8/node_modules/call-bind/index.js");
@@ -9579,12 +9579,18 @@ __webpack_require__.add({
9579
9579
  var superProto = getProto(proto);
9580
9580
  descriptor = gOPD(superProto, Symbol.toStringTag);
9581
9581
  }
9582
- cache['$' + typedArray] = callBind(descriptor.get);
9582
+ if (descriptor && descriptor.get) {
9583
+ var bound = callBind(descriptor.get);
9584
+ cache['$' + typedArray] = bound;
9585
+ }
9583
9586
  }
9584
9587
  }) : forEach(typedArrays, function(typedArray) {
9585
9588
  var arr = new g[typedArray]();
9586
9589
  var fn = arr.slice || arr.set;
9587
- if (fn) cache['$' + typedArray] = callBind(fn);
9590
+ if (fn) {
9591
+ var bound = callBind(fn);
9592
+ cache['$' + typedArray] = bound;
9593
+ }
9588
9594
  });
9589
9595
  var tryTypedArrays = function(value) {
9590
9596
  var found = false;
@@ -18199,6 +18205,7 @@ __webpack_require__("../../node_modules/.pnpm/process@0.11.10/node_modules/proce
18199
18205
  const REAL_TIMERS = {};
18200
18206
  const setRealTimers = ()=>{
18201
18207
  REAL_TIMERS.setTimeout ??= globalThis.setTimeout.bind(globalThis);
18208
+ REAL_TIMERS.clearTimeout ??= globalThis.clearTimeout.bind(globalThis);
18202
18209
  };
18203
18210
  const getRealTimers = ()=>REAL_TIMERS;
18204
18211
  const formatTestError = (err, test)=>{
@@ -20658,6 +20665,9 @@ function createExpect({ getCurrentTest, workerState }) {
20658
20665
  soft: true
20659
20666
  });
20660
20667
  expect.poll = createExpectPoll(expect);
20668
+ expect.element = ()=>{
20669
+ throw new Error("expect.element() is only available in browser mode. Enable browser mode in config and import @rstest/browser to install the browser expect adapter.");
20670
+ };
20661
20671
  expect.unreachable = (message)=>{
20662
20672
  chai_assert.fail(`expected ${message ? `"${message}" ` : ''}not to be reached`);
20663
20673
  };
@@ -20806,7 +20816,7 @@ function getFixtureUsedProps(fn) {
20806
20816
  const trimmedParams = match[1].trim();
20807
20817
  if (!trimmedParams) return [];
20808
20818
  const [firstParam] = splitByComma(trimmedParams);
20809
- if (firstParam?.[0] !== '{' || '}' !== firstParam[firstParam.length - 1]) {
20819
+ if (firstParam?.[0] !== '{' || !firstParam.endsWith('}')) {
20810
20820
  if (firstParam?.startsWith('_')) return [];
20811
20821
  throw new Error(`First argument must use the object destructuring pattern: ${firstParam}`);
20812
20822
  }
@@ -20959,18 +20969,10 @@ function limitConcurrency(concurrency = 1 / 0) {
20959
20969
  });
20960
20970
  }
20961
20971
  var runner_process = __webpack_require__("../../node_modules/.pnpm/process@0.11.10/node_modules/process/browser.js");
20962
- function runner_define_property(obj, key, value) {
20963
- if (key in obj) Object.defineProperty(obj, key, {
20964
- value: value,
20965
- enumerable: true,
20966
- configurable: true,
20967
- writable: true
20968
- });
20969
- else obj[key] = value;
20970
- return obj;
20971
- }
20972
20972
  const RealDate = Date;
20973
20973
  class TestRunner {
20974
+ _test;
20975
+ workerState;
20974
20976
  async runTests({ tests, testPath, state, hooks, api, snapshotClient }) {
20975
20977
  this.workerState = state;
20976
20978
  const { runtimeConfig: { passWithNoTests, retry, maxConcurrency, bail }, project } = state;
@@ -21157,7 +21159,8 @@ class TestRunner {
21157
21159
  project: test.project,
21158
21160
  testId: test.testId,
21159
21161
  type: 'suite',
21160
- location: test.location
21162
+ location: test.location,
21163
+ runMode: test.runMode
21161
21164
  });
21162
21165
  if (0 === test.tests.length) {
21163
21166
  if ([
@@ -21229,7 +21232,8 @@ class TestRunner {
21229
21232
  parentNames: test.parentNames,
21230
21233
  project: test.project,
21231
21234
  type: 'case',
21232
- location: test.location
21235
+ location: test.location,
21236
+ runMode: test.runMode
21233
21237
  });
21234
21238
  do {
21235
21239
  const currentResult = await runTestsCase(test, parentHooks);
@@ -21388,10 +21392,6 @@ class TestRunner {
21388
21392
  if (null !== expectedAssertionsNumber && assertionCalls !== expectedAssertionsNumber) throw expectedAssertionsNumberErrorGen();
21389
21393
  if (true === isExpectingAssertions && 0 === assertionCalls) throw isExpectingAssertionsError;
21390
21394
  }
21391
- constructor(){
21392
- runner_define_property(this, "_test", void 0);
21393
- runner_define_property(this, "workerState", void 0);
21394
- }
21395
21395
  }
21396
21396
  var UNKNOWN_FUNCTION = '<unknown>';
21397
21397
  function stack_trace_parser_esm_parse(stackString) {
@@ -21497,17 +21497,21 @@ function fileURLToPath(url, options) {
21497
21497
  }
21498
21498
  return path;
21499
21499
  }
21500
- function runtime_define_property(obj, key, value) {
21501
- if (key in obj) Object.defineProperty(obj, key, {
21502
- value: value,
21503
- enumerable: true,
21504
- configurable: true,
21505
- writable: true
21506
- });
21507
- else obj[key] = value;
21508
- return obj;
21509
- }
21510
21500
  class RunnerRuntime {
21501
+ tests = [];
21502
+ _currentTest = [];
21503
+ testPath;
21504
+ status = 'collect';
21505
+ collectStatus = 'lazy';
21506
+ currentCollectList = [];
21507
+ runtimeConfig;
21508
+ project;
21509
+ testId = 1;
21510
+ constructor({ testPath, runtimeConfig, project }){
21511
+ this.project = project;
21512
+ this.testPath = testPath;
21513
+ this.runtimeConfig = runtimeConfig;
21514
+ }
21511
21515
  updateStatus(status) {
21512
21516
  this.status = status;
21513
21517
  }
@@ -21731,20 +21735,6 @@ class RunnerRuntime {
21731
21735
  }
21732
21736
  throw new Error('Expect to find a suite, but got undefined');
21733
21737
  }
21734
- constructor({ testPath, runtimeConfig, project }){
21735
- runtime_define_property(this, "tests", []);
21736
- runtime_define_property(this, "_currentTest", []);
21737
- runtime_define_property(this, "testPath", void 0);
21738
- runtime_define_property(this, "status", 'collect');
21739
- runtime_define_property(this, "collectStatus", 'lazy');
21740
- runtime_define_property(this, "currentCollectList", []);
21741
- runtime_define_property(this, "runtimeConfig", void 0);
21742
- runtime_define_property(this, "project", void 0);
21743
- runtime_define_property(this, "testId", 1);
21744
- this.project = project;
21745
- this.testPath = testPath;
21746
- this.runtimeConfig = runtimeConfig;
21747
- }
21748
21738
  }
21749
21739
  const createRuntimeAPI = ({ testPath, runtimeConfig, project })=>{
21750
21740
  const runtimeInstance = new RunnerRuntime({
@@ -21965,18 +21955,7 @@ function createRunner({ workerState }) {
21965
21955
  traverseUpdateTest(tests, testNamePattern);
21966
21956
  hooks.onTestFileReady?.({
21967
21957
  testPath,
21968
- tests: tests.map(function toTestInfo(test) {
21969
- return {
21970
- testId: test.testId,
21971
- name: test.name,
21972
- parentNames: test.parentNames,
21973
- testPath: test.testPath,
21974
- project: test.project,
21975
- type: test.type,
21976
- location: test.location,
21977
- tests: 'suite' === test.type ? test.tests.map(toTestInfo) : []
21978
- };
21979
- })
21958
+ tests: tests.map(toTestInfo)
21980
21959
  });
21981
21960
  runtime.instance.updateStatus('running');
21982
21961
  const results = await testRunner.runTests({
@@ -21992,26 +21971,38 @@ function createRunner({ workerState }) {
21992
21971
  collectTests: async ()=>{
21993
21972
  const tests = await runtime.instance.getTests();
21994
21973
  traverseUpdateTest(tests, testNamePattern);
21995
- return tests;
21974
+ return tests.map(toTestInfo);
21996
21975
  },
21997
21976
  getCurrentTest: ()=>testRunner.getCurrentTest()
21998
21977
  }
21999
21978
  };
22000
21979
  }
21980
+ function toTestInfo(test) {
21981
+ return {
21982
+ testId: test.testId,
21983
+ name: test.name,
21984
+ parentNames: test.parentNames,
21985
+ testPath: test.testPath,
21986
+ project: test.project,
21987
+ type: test.type,
21988
+ location: test.location,
21989
+ tests: 'suite' === test.type ? test.tests.map(toTestInfo) : [],
21990
+ runMode: test.runMode
21991
+ };
21992
+ }
22001
21993
  const fake_timers_src = __webpack_require__("../../node_modules/.pnpm/@sinonjs+fake-timers@15.1.0/node_modules/@sinonjs/fake-timers/src/fake-timers-src.js");
22002
21994
  var fakeTimers_process = __webpack_require__("../../node_modules/.pnpm/process@0.11.10/node_modules/process/browser.js");
22003
- function fakeTimers_define_property(obj, key, value) {
22004
- if (key in obj) Object.defineProperty(obj, key, {
22005
- value: value,
22006
- enumerable: true,
22007
- configurable: true,
22008
- writable: true
22009
- });
22010
- else obj[key] = value;
22011
- return obj;
22012
- }
22013
21995
  const fakeTimers_RealDate = Date;
22014
21996
  class FakeTimers {
21997
+ _clock;
21998
+ _config;
21999
+ _fakingTime;
22000
+ _fakeTimers;
22001
+ constructor({ global, config = {} }){
22002
+ this._config = config;
22003
+ this._fakingTime = false;
22004
+ this._fakeTimers = (0, fake_timers_src.withGlobal)(global);
22005
+ }
22015
22006
  clearAllTimers() {
22016
22007
  if (this._fakingTime) this._clock.reset();
22017
22008
  }
@@ -22107,15 +22098,6 @@ class FakeTimers {
22107
22098
  isFakeTimers() {
22108
22099
  return this._fakingTime;
22109
22100
  }
22110
- constructor({ global, config = {} }){
22111
- fakeTimers_define_property(this, "_clock", void 0);
22112
- fakeTimers_define_property(this, "_config", void 0);
22113
- fakeTimers_define_property(this, "_fakingTime", void 0);
22114
- fakeTimers_define_property(this, "_fakeTimers", void 0);
22115
- this._config = config;
22116
- this._fakingTime = false;
22117
- this._fakeTimers = (0, fake_timers_src.withGlobal)(global);
22118
- }
22119
22101
  }
22120
22102
  function getTypeName(value) {
22121
22103
  return Object.prototype.toString.call(value).slice(8, -1);
@@ -22241,7 +22223,7 @@ function mockObject(options, object, mockExports = {}) {
22241
22223
  configurable: descriptor.configurable,
22242
22224
  enumerable: descriptor.enumerable,
22243
22225
  get: ()=>void 0,
22244
- set: descriptor.set ? ()=>{} : void 0
22226
+ set: descriptor.set ? ()=>void 0 : void 0
22245
22227
  });
22246
22228
  } catch {}
22247
22229
  continue;
@@ -22452,11 +22434,34 @@ const initSpy = ()=>{
22452
22434
  };
22453
22435
  };
22454
22436
  var utilities_process = __webpack_require__("../../node_modules/.pnpm/process@0.11.10/node_modules/process/browser.js");
22437
+ const DEFAULT_WAIT_TIMEOUT = 1000;
22438
+ const DEFAULT_WAIT_INTERVAL = 50;
22439
+ const getRealSetTimeout = ()=>getRealTimers().setTimeout ?? globalThis.setTimeout.bind(globalThis);
22440
+ const getRealClearTimeout = ()=>getRealTimers().clearTimeout ?? globalThis.clearTimeout.bind(globalThis);
22441
+ const sleep = (ms)=>new Promise((resolve)=>getRealSetTimeout()(resolve, ms));
22442
+ const createWaitForTimeoutError = (timeout, cause)=>new Error(`waitFor timed out in ${timeout}ms`, {
22443
+ cause
22444
+ });
22445
+ const createWaitUntilTimeoutError = (timeout)=>new Error(`waitUntil timed out in ${timeout}ms`);
22446
+ const normalizeWaitOptions = (options)=>({
22447
+ timeout: Math.max(0, 'number' == typeof options ? options : options?.timeout ?? DEFAULT_WAIT_TIMEOUT),
22448
+ interval: Math.max(0, 'number' == typeof options ? DEFAULT_WAIT_INTERVAL : options?.interval ?? DEFAULT_WAIT_INTERVAL)
22449
+ });
22455
22450
  const createRstestUtilities = async (workerState)=>{
22451
+ const RSTEST_ENV_SYMBOL = Symbol.for('rstest.env');
22456
22452
  const originalEnvValues = new Map();
22457
22453
  const originalGlobalValues = new Map();
22458
22454
  let _timers;
22459
22455
  let originalConfig;
22456
+ const resolveRuntimeEnv = ()=>{
22457
+ const globalRef = globalThis;
22458
+ const runtimeEnv = globalRef[RSTEST_ENV_SYMBOL];
22459
+ if (runtimeEnv && 'object' == typeof runtimeEnv) return runtimeEnv;
22460
+ if (void 0 !== utilities_process && utilities_process.env) return utilities_process.env;
22461
+ const createdEnv = {};
22462
+ globalRef[RSTEST_ENV_SYMBOL] = createdEnv;
22463
+ return createdEnv;
22464
+ };
22460
22465
  const timers = ()=>{
22461
22466
  if (!_timers) _timers = new FakeTimers({
22462
22467
  global: globalThis
@@ -22494,15 +22499,15 @@ const createRstestUtilities = async (workerState)=>{
22494
22499
  for (const mock of mocks)mock.mockRestore();
22495
22500
  return rstest;
22496
22501
  },
22497
- mock: ()=>{},
22498
- mockRequire: ()=>{},
22499
- doMock: ()=>{},
22500
- doMockRequire: ()=>{},
22501
- unmock: ()=>{},
22502
- doUnmock: ()=>{},
22503
- importMock: async ()=>({}),
22502
+ mock: ()=>void 0,
22503
+ mockRequire: ()=>void 0,
22504
+ doMock: ()=>void 0,
22505
+ doMockRequire: ()=>void 0,
22506
+ unmock: ()=>void 0,
22507
+ doUnmock: ()=>void 0,
22508
+ importMock: ()=>Promise.resolve({}),
22504
22509
  requireMock: ()=>({}),
22505
- importActual: async ()=>({}),
22510
+ importActual: ()=>Promise.resolve({}),
22506
22511
  requireActual: ()=>({}),
22507
22512
  resetModules: ()=>({}),
22508
22513
  hoisted: ()=>({}),
@@ -22528,14 +22533,16 @@ const createRstestUtilities = async (workerState)=>{
22528
22533
  if (originalConfig) Object.assign(workerState.runtimeConfig, originalConfig);
22529
22534
  },
22530
22535
  stubEnv: (name, value)=>{
22531
- if (!originalEnvValues.has(name)) originalEnvValues.set(name, utilities_process.env[name]);
22532
- if (void 0 === value) delete utilities_process.env[name];
22533
- else utilities_process.env[name] = value;
22536
+ const runtimeEnv = resolveRuntimeEnv();
22537
+ if (!originalEnvValues.has(name)) originalEnvValues.set(name, runtimeEnv[name]);
22538
+ if (void 0 === value) delete runtimeEnv[name];
22539
+ else runtimeEnv[name] = value;
22534
22540
  return rstest;
22535
22541
  },
22536
22542
  unstubAllEnvs: ()=>{
22537
- for (const [name, value] of originalEnvValues)if (void 0 === value) delete utilities_process.env[name];
22538
- else utilities_process.env[name] = value;
22543
+ const runtimeEnv = resolveRuntimeEnv();
22544
+ for (const [name, value] of originalEnvValues)if (void 0 === value) delete runtimeEnv[name];
22545
+ else runtimeEnv[name] = value;
22539
22546
  originalEnvValues.clear();
22540
22547
  return rstest;
22541
22548
  },
@@ -22615,6 +22622,51 @@ const createRstestUtilities = async (workerState)=>{
22615
22622
  clearAllTimers: ()=>{
22616
22623
  timers().clearAllTimers();
22617
22624
  return rstest;
22625
+ },
22626
+ waitFor: async (callback, options)=>{
22627
+ const { timeout, interval } = normalizeWaitOptions(options);
22628
+ const clearTimeoutFn = getRealClearTimeout();
22629
+ let timedOut = false;
22630
+ let lastError;
22631
+ const timeoutId = getRealSetTimeout()(()=>{
22632
+ timedOut = true;
22633
+ }, timeout);
22634
+ try {
22635
+ while(true){
22636
+ if (timedOut) throw lastError ?? createWaitForTimeoutError(timeout);
22637
+ try {
22638
+ const value = await callback();
22639
+ if (timedOut) throw lastError ?? createWaitForTimeoutError(timeout);
22640
+ return value;
22641
+ } catch (error) {
22642
+ lastError = error;
22643
+ }
22644
+ if (timedOut) throw lastError ?? createWaitForTimeoutError(timeout);
22645
+ await sleep(interval);
22646
+ }
22647
+ } finally{
22648
+ clearTimeoutFn(timeoutId);
22649
+ }
22650
+ },
22651
+ waitUntil: async (callback, options)=>{
22652
+ const { timeout, interval } = normalizeWaitOptions(options);
22653
+ const clearTimeoutFn = getRealClearTimeout();
22654
+ let timedOut = false;
22655
+ const timeoutId = getRealSetTimeout()(()=>{
22656
+ timedOut = true;
22657
+ }, timeout);
22658
+ try {
22659
+ while(true){
22660
+ if (timedOut) throw createWaitUntilTimeoutError(timeout);
22661
+ const value = await callback();
22662
+ if (timedOut) throw createWaitUntilTimeoutError(timeout);
22663
+ if (value) return value;
22664
+ if (timedOut) throw createWaitUntilTimeoutError(timeout);
22665
+ await sleep(interval);
22666
+ }
22667
+ } finally{
22668
+ clearTimeoutFn(timeoutId);
22669
+ }
22618
22670
  }
22619
22671
  };
22620
22672
  return rstest;
@@ -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 {