@rstest/core 0.0.3 → 0.0.5

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/dist/867.js CHANGED
@@ -277,6 +277,8 @@ export const __webpack_modules__ = {
277
277
  const isNot = utils.flag(this, 'negate');
278
278
  if (isNot) throw new Error('toThrowErrorMatchingInlineSnapshot cannot be used with "not"');
279
279
  const test = getTest('toThrowErrorMatchingInlineSnapshot', this);
280
+ const isInsideEach = test.each || test.inTestEach;
281
+ if (isInsideEach) throw new Error('InlineSnapshot cannot be used inside of test.each or describe.each');
280
282
  const expected = utils.flag(this, 'object');
281
283
  const error = utils.flag(this, 'error');
282
284
  const promise = utils.flag(this, 'promise');
@@ -675,7 +677,7 @@ export const __webpack_modules__ = {
675
677
  }
676
678
  ]
677
679
  };
678
- } catch (error) {
680
+ } catch (_err) {
679
681
  result = {
680
682
  status: 'pass',
681
683
  parentNames: test.parentNames,
@@ -811,6 +813,7 @@ export const __webpack_modules__ = {
811
813
  retryCount++;
812
814
  }while (retryCount <= retry && 'fail' === result.status);
813
815
  result.duration = RealDate.now() - start;
816
+ result.retryCount = retryCount - 1;
814
817
  hooks.onTestCaseResult?.(result);
815
818
  results.push(result);
816
819
  }
@@ -1591,10 +1594,13 @@ export const __webpack_modules__ = {
1591
1594
  return rstest;
1592
1595
  },
1593
1596
  mock: ()=>{},
1597
+ mockRequire: ()=>{},
1594
1598
  doMock: ()=>{},
1595
- unMock: ()=>{},
1596
- doUnMock: ()=>{},
1599
+ doMockRequire: ()=>{},
1600
+ unmock: ()=>{},
1601
+ doUnmock: ()=>{},
1597
1602
  importMock: async ()=>({}),
1603
+ requireMock: ()=>({}),
1598
1604
  importActual: async ()=>({}),
1599
1605
  requireActual: ()=>({}),
1600
1606
  resetModules: ()=>rstest,
@@ -1725,11 +1731,11 @@ export const __webpack_modules__ = {
1725
1731
  $_: ()=>helper.$_,
1726
1732
  Yz: ()=>helper.Yz
1727
1733
  });
1734
+ var constants = __webpack_require__("./src/utils/constants.ts");
1728
1735
  var helper = __webpack_require__("./src/utils/helper.ts");
1729
1736
  __webpack_require__("./src/utils/logger.ts");
1730
1737
  __webpack_require__("node:fs");
1731
1738
  __webpack_require__("node:fs/promises");
1732
1739
  __webpack_require__("pathe");
1733
- var constants = __webpack_require__("./src/utils/constants.ts");
1734
1740
  }
1735
1741
  };
package/dist/cli.js CHANGED
@@ -2292,6 +2292,8 @@ var __webpack_modules__ = {
2292
2292
  $_: ()=>picocolors__WEBPACK_IMPORTED_MODULE_2___default.a,
2293
2293
  AS: ()=>prettyTime,
2294
2294
  H: ()=>parsePosix,
2295
+ PA: ()=>needFlagExperimentalDetectModule,
2296
+ Tn: ()=>NODE_BUILTINS,
2295
2297
  XQ: ()=>castArray,
2296
2298
  Yz: ()=>getTaskNameWithPrefix,
2297
2299
  Z: ()=>formatError,
@@ -2354,11 +2356,85 @@ var __webpack_modules__ = {
2354
2356
  testNamePattern: testNamePattern && 'string' != typeof testNamePattern ? wrapRegex(testNamePattern) : testNamePattern
2355
2357
  };
2356
2358
  };
2357
- const getNodeVersion = ()=>'string' == typeof process.versions?.node ? process.versions.node.split('.').map(Number) : [
2358
- 0,
2359
- 0,
2360
- 0
2361
- ];
2359
+ const getNodeVersion = ()=>{
2360
+ if ('string' == typeof process.versions?.node) {
2361
+ const [major = 0, minor = 0, patch = 0] = process.versions.node.split('.').map(Number);
2362
+ return {
2363
+ major,
2364
+ minor,
2365
+ patch
2366
+ };
2367
+ }
2368
+ return {
2369
+ major: 0,
2370
+ minor: 0,
2371
+ patch: 0
2372
+ };
2373
+ };
2374
+ const needFlagExperimentalDetectModule = ()=>{
2375
+ const { major, minor } = getNodeVersion();
2376
+ if (20 === major && minor >= 10) return true;
2377
+ if (22 === major && minor < 7) return true;
2378
+ return false;
2379
+ };
2380
+ const NODE_BUILTINS = [
2381
+ 'assert',
2382
+ 'assert/strict',
2383
+ 'async_hooks',
2384
+ 'buffer',
2385
+ 'child_process',
2386
+ 'cluster',
2387
+ 'console',
2388
+ 'constants',
2389
+ 'crypto',
2390
+ 'dgram',
2391
+ 'diagnostics_channel',
2392
+ 'dns',
2393
+ 'dns/promises',
2394
+ 'domain',
2395
+ 'events',
2396
+ 'fs',
2397
+ 'fs/promises',
2398
+ 'http',
2399
+ 'http2',
2400
+ 'https',
2401
+ 'inspector',
2402
+ 'inspector/promises',
2403
+ 'module',
2404
+ 'net',
2405
+ 'os',
2406
+ 'path',
2407
+ 'path/posix',
2408
+ 'path/win32',
2409
+ 'perf_hooks',
2410
+ 'process',
2411
+ 'punycode',
2412
+ 'querystring',
2413
+ 'readline',
2414
+ 'readline/promises',
2415
+ 'repl',
2416
+ 'stream',
2417
+ 'stream/consumers',
2418
+ 'stream/promises',
2419
+ 'stream/web',
2420
+ 'string_decoder',
2421
+ 'sys',
2422
+ 'timers',
2423
+ 'timers/promises',
2424
+ 'tls',
2425
+ 'trace_events',
2426
+ 'tty',
2427
+ 'url',
2428
+ 'util',
2429
+ 'util/types',
2430
+ 'v8',
2431
+ 'vm',
2432
+ 'wasi',
2433
+ 'worker_threads',
2434
+ 'zlib',
2435
+ /^node:/,
2436
+ 'pnpapi'
2437
+ ];
2362
2438
  },
2363
2439
  "./src/utils/index.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
2364
2440
  __webpack_require__.d(__webpack_exports__, {
@@ -2371,15 +2447,18 @@ var __webpack_modules__ = {
2371
2447
  mP: ()=>helper.mP,
2372
2448
  Ps: ()=>formatTestPath,
2373
2449
  XQ: ()=>helper.XQ,
2374
- $_: ()=>helper.$_,
2375
2450
  Nk: ()=>constants.Nk,
2451
+ Tn: ()=>helper.Tn,
2452
+ $_: ()=>helper.$_,
2376
2453
  Yz: ()=>helper.Yz,
2454
+ PA: ()=>helper.PA,
2377
2455
  L1: ()=>logger.L,
2378
2456
  v8: ()=>helper.v8,
2379
2457
  Qd: ()=>constants.Qd,
2380
2458
  f1: ()=>constants.f1,
2381
2459
  AS: ()=>helper.AS
2382
2460
  });
2461
+ var constants = __webpack_require__("./src/utils/constants.ts");
2383
2462
  var helper = __webpack_require__("./src/utils/helper.ts");
2384
2463
  var logger = __webpack_require__("./src/utils/logger.ts");
2385
2464
  var external_node_fs_ = __webpack_require__("node:fs");
@@ -2455,7 +2534,6 @@ var __webpack_modules__ = {
2455
2534
  if (external_pathe_["default"].isAbsolute(testPath) && testPath.includes(root)) testPath = external_pathe_["default"].relative(root, testPath);
2456
2535
  return prettyTestPath(testPath);
2457
2536
  };
2458
- var constants = __webpack_require__("./src/utils/constants.ts");
2459
2537
  },
2460
2538
  "./src/utils/logger.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
2461
2539
  __webpack_require__.d(__webpack_exports__, {
@@ -3587,7 +3665,7 @@ function prepareCli() {
3587
3665
  if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) console.log();
3588
3666
  }
3589
3667
  function showRstest() {
3590
- logger.k.greet(" Rstest v0.0.3");
3668
+ logger.k.greet(" Rstest v0.0.5");
3591
3669
  logger.k.log('');
3592
3670
  }
3593
3671
  const applyCommonOptions = (cli)=>{
@@ -3631,7 +3709,7 @@ async function initCli(options) {
3631
3709
  function setupCommands() {
3632
3710
  const cli = dist('rstest');
3633
3711
  cli.help();
3634
- cli.version("0.0.3");
3712
+ cli.version("0.0.5");
3635
3713
  applyCommonOptions(cli);
3636
3714
  cli.command('[...filters]', 'run tests').action(async (filters, options)=>{
3637
3715
  showRstest();
@@ -0,0 +1,22 @@
1
+ const CSS_MODULES_REGEX = /\.module\.\w+$/i;
2
+ const isCSSModules = ({ resourcePath, resourceQuery, resourceFragment, modules })=>{
3
+ if ('boolean' == typeof modules) return modules;
4
+ if ('string' == typeof modules) return 'global' !== modules;
5
+ const { auto } = modules;
6
+ if ('boolean' == typeof auto) return auto && CSS_MODULES_REGEX.test(resourcePath);
7
+ if (auto instanceof RegExp) return auto.test(resourcePath);
8
+ if ('function' == typeof auto) return auto(resourcePath, resourceQuery, resourceFragment);
9
+ return true;
10
+ };
11
+ function loader(content) {
12
+ const { resourcePath, resourceQuery, resourceFragment } = this;
13
+ const { modules = true } = this.getOptions() || {};
14
+ if (isCSSModules({
15
+ resourcePath,
16
+ resourceQuery,
17
+ resourceFragment,
18
+ modules
19
+ })) return content;
20
+ return '';
21
+ }
22
+ export { loader as default };
package/dist/worker.js CHANGED
@@ -2887,7 +2887,7 @@ var __webpack_modules__ = {
2887
2887
  return -1 !== position && (-1 === terminatorPosition || position < terminatorPosition);
2888
2888
  };
2889
2889
  },
2890
- "../../node_modules/.pnpm/jest-diff@30.0.2/node_modules/jest-diff/build/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
2890
+ "../../node_modules/.pnpm/jest-diff@30.0.3/node_modules/jest-diff/build/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
2891
2891
  /*!
2892
2892
  * /**
2893
2893
  * * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -3201,6 +3201,7 @@ var __webpack_modules__ = {
3201
3201
  exports.printDiffLines = exports.diffLinesUnified2 = exports.diffLinesUnified = exports.diffLinesRaw = void 0;
3202
3202
  var _diffSequences = _interopRequireDefault(__webpack_require__("../../node_modules/.pnpm/@jest+diff-sequences@30.0.1/node_modules/@jest/diff-sequences/build/index.js"));
3203
3203
  var _cleanupSemantic = __nested_webpack_require_20541_20560__("./src/cleanupSemantic.ts");
3204
+ var _escapeControlCharacters = __nested_webpack_require_20541_20560__("./src/escapeControlCharacters.ts");
3204
3205
  var _joinAlignedDiffs = __nested_webpack_require_20541_20560__("./src/joinAlignedDiffs.ts");
3205
3206
  var _normalizeDiffOptions = __nested_webpack_require_20541_20560__("./src/normalizeDiffOptions.ts");
3206
3207
  function _interopRequireDefault(e) {
@@ -3247,7 +3248,7 @@ var __webpack_modules__ = {
3247
3248
  };
3248
3249
  const printDiffLines = (diffs, options)=>printAnnotation(options, countChanges(diffs)) + (options.expand ? (0, _joinAlignedDiffs.joinAlignedDiffsExpand)(diffs, options) : (0, _joinAlignedDiffs.joinAlignedDiffsNoExpand)(diffs, options));
3249
3250
  exports.printDiffLines = printDiffLines;
3250
- const diffLinesUnified = (aLines, bLines, options)=>printDiffLines(diffLinesRaw(isEmptyString(aLines) ? [] : aLines, isEmptyString(bLines) ? [] : bLines), (0, _normalizeDiffOptions.normalizeDiffOptions)(options));
3251
+ const diffLinesUnified = (aLines, bLines, options)=>printDiffLines(diffLinesRaw(isEmptyString(aLines) ? [] : aLines.map(_escapeControlCharacters.escapeControlCharacters), isEmptyString(bLines) ? [] : bLines.map(_escapeControlCharacters.escapeControlCharacters)), (0, _normalizeDiffOptions.normalizeDiffOptions)(options));
3251
3252
  exports.diffLinesUnified = diffLinesUnified;
3252
3253
  const diffLinesUnified2 = (aLinesDisplay, bLinesDisplay, aLinesCompare, bLinesCompare, options)=>{
3253
3254
  if (isEmptyString(aLinesDisplay) && isEmptyString(aLinesCompare)) {
@@ -3298,13 +3299,13 @@ var __webpack_modules__ = {
3298
3299
  };
3299
3300
  exports.diffLinesRaw = diffLinesRaw;
3300
3301
  },
3301
- "./src/diffStrings.ts": (__unused_webpack_module, exports, __nested_webpack_require_26333_26352__)=>{
3302
+ "./src/diffStrings.ts": (__unused_webpack_module, exports, __nested_webpack_require_26529_26548__)=>{
3302
3303
  Object.defineProperty(exports, "__esModule", {
3303
3304
  value: true
3304
3305
  });
3305
3306
  exports["default"] = void 0;
3306
3307
  var _diffSequences = _interopRequireDefault(__webpack_require__("../../node_modules/.pnpm/@jest+diff-sequences@30.0.1/node_modules/@jest/diff-sequences/build/index.js"));
3307
- var _cleanupSemantic = __nested_webpack_require_26333_26352__("./src/cleanupSemantic.ts");
3308
+ var _cleanupSemantic = __nested_webpack_require_26529_26548__("./src/cleanupSemantic.ts");
3308
3309
  function _interopRequireDefault(e) {
3309
3310
  return e && e.__esModule ? e : {
3310
3311
  default: e
@@ -3329,12 +3330,34 @@ var __webpack_modules__ = {
3329
3330
  };
3330
3331
  exports["default"] = diffStrings;
3331
3332
  },
3332
- "./src/getAlignedDiffs.ts": (__unused_webpack_module, exports, __nested_webpack_require_28166_28185__)=>{
3333
+ "./src/escapeControlCharacters.ts": (__unused_webpack_module, exports)=>{
3334
+ Object.defineProperty(exports, "__esModule", {
3335
+ value: true
3336
+ });
3337
+ exports.escapeControlCharacters = void 0;
3338
+ const escapeControlCharacters = (str)=>str.replaceAll(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F]/g, (match)=>{
3339
+ switch(match){
3340
+ case '\b':
3341
+ return '\\b';
3342
+ case '\f':
3343
+ return '\\f';
3344
+ case '\v':
3345
+ return '\\v';
3346
+ default:
3347
+ {
3348
+ const code = match.codePointAt(0);
3349
+ return `\\x${code.toString(16).padStart(2, '0')}`;
3350
+ }
3351
+ }
3352
+ });
3353
+ exports.escapeControlCharacters = escapeControlCharacters;
3354
+ },
3355
+ "./src/getAlignedDiffs.ts": (__unused_webpack_module, exports, __nested_webpack_require_29271_29290__)=>{
3333
3356
  Object.defineProperty(exports, "__esModule", {
3334
3357
  value: true
3335
3358
  });
3336
3359
  exports["default"] = void 0;
3337
- var _cleanupSemantic = __nested_webpack_require_28166_28185__("./src/cleanupSemantic.ts");
3360
+ var _cleanupSemantic = __nested_webpack_require_29271_29290__("./src/cleanupSemantic.ts");
3338
3361
  const concatenateRelevantDiffs = (op, diffs, changeColor)=>diffs.reduce((reduced, diff)=>reduced + (diff[0] === _cleanupSemantic.DIFF_EQUAL ? diff[1] : diff[0] === op && diff[1].length > 0 ? changeColor(diff[1]) : ''), '');
3339
3362
  class ChangeBuffer {
3340
3363
  op;
@@ -3440,12 +3463,12 @@ var __webpack_modules__ = {
3440
3463
  };
3441
3464
  exports["default"] = getAlignedDiffs;
3442
3465
  },
3443
- "./src/joinAlignedDiffs.ts": (__unused_webpack_module, exports, __nested_webpack_require_35036_35055__)=>{
3466
+ "./src/joinAlignedDiffs.ts": (__unused_webpack_module, exports, __nested_webpack_require_36141_36160__)=>{
3444
3467
  Object.defineProperty(exports, "__esModule", {
3445
3468
  value: true
3446
3469
  });
3447
3470
  exports.joinAlignedDiffsNoExpand = exports.joinAlignedDiffsExpand = void 0;
3448
- var _cleanupSemantic = __nested_webpack_require_35036_35055__("./src/cleanupSemantic.ts");
3471
+ var _cleanupSemantic = __nested_webpack_require_36141_36160__("./src/cleanupSemantic.ts");
3449
3472
  const formatTrailingSpaces = (line, trailingSpaceFormatter)=>line.replace(/\s+$/, (match)=>trailingSpaceFormatter(match));
3450
3473
  const printDiffLine = (line, isFirstOrLast, color, indicator, trailingSpaceFormatter, emptyFirstOrLastLinePlaceholder)=>0 === line.length ? ' ' === indicator ? isFirstOrLast && emptyFirstOrLastLinePlaceholder.length > 0 ? color(`${indicator} ${emptyFirstOrLastLinePlaceholder}`) : '' : color(indicator) : color(`${indicator} ${formatTrailingSpaces(line, trailingSpaceFormatter)}`);
3451
3474
  const printDeleteLine = (line, isFirstOrLast, { aColor, aIndicator, changeLineTrailingSpaceColor, emptyFirstOrLastLinePlaceholder })=>printDiffLine(line, isFirstOrLast, aColor, aIndicator, changeLineTrailingSpaceColor, emptyFirstOrLastLinePlaceholder);
@@ -3613,16 +3636,16 @@ var __webpack_modules__ = {
3613
3636
  });
3614
3637
  exports.normalizeDiffOptions = normalizeDiffOptions;
3615
3638
  },
3616
- "./src/printDiffs.ts": (__unused_webpack_module, exports, __nested_webpack_require_44431_44450__)=>{
3639
+ "./src/printDiffs.ts": (__unused_webpack_module, exports, __nested_webpack_require_45536_45555__)=>{
3617
3640
  Object.defineProperty(exports, "__esModule", {
3618
3641
  value: true
3619
3642
  });
3620
3643
  exports.diffStringsUnified = exports.diffStringsRaw = void 0;
3621
- var _cleanupSemantic = __nested_webpack_require_44431_44450__("./src/cleanupSemantic.ts");
3622
- var _diffLines = __nested_webpack_require_44431_44450__("./src/diffLines.ts");
3623
- var _diffStrings = _interopRequireDefault(__nested_webpack_require_44431_44450__("./src/diffStrings.ts"));
3624
- var _getAlignedDiffs = _interopRequireDefault(__nested_webpack_require_44431_44450__("./src/getAlignedDiffs.ts"));
3625
- var _normalizeDiffOptions = __nested_webpack_require_44431_44450__("./src/normalizeDiffOptions.ts");
3644
+ var _cleanupSemantic = __nested_webpack_require_45536_45555__("./src/cleanupSemantic.ts");
3645
+ var _diffLines = __nested_webpack_require_45536_45555__("./src/diffLines.ts");
3646
+ var _diffStrings = _interopRequireDefault(__nested_webpack_require_45536_45555__("./src/diffStrings.ts"));
3647
+ var _getAlignedDiffs = _interopRequireDefault(__nested_webpack_require_45536_45555__("./src/getAlignedDiffs.ts"));
3648
+ var _normalizeDiffOptions = __nested_webpack_require_45536_45555__("./src/normalizeDiffOptions.ts");
3626
3649
  function _interopRequireDefault(e) {
3627
3650
  return e && e.__esModule ? e : {
3628
3651
  default: e
@@ -3657,13 +3680,13 @@ var __webpack_modules__ = {
3657
3680
  }
3658
3681
  };
3659
3682
  var __webpack_module_cache__ = {};
3660
- function __nested_webpack_require_47190__(moduleId) {
3683
+ function __nested_webpack_require_48295__(moduleId) {
3661
3684
  var cachedModule = __webpack_module_cache__[moduleId];
3662
3685
  if (void 0 !== cachedModule) return cachedModule.exports;
3663
3686
  var module = __webpack_module_cache__[moduleId] = {
3664
3687
  exports: {}
3665
3688
  };
3666
- __webpack_modules__[moduleId](module, module.exports, __nested_webpack_require_47190__);
3689
+ __webpack_modules__[moduleId](module, module.exports, __nested_webpack_require_48295__);
3667
3690
  return module.exports;
3668
3691
  }
3669
3692
  var __nested_webpack_exports__ = {};
@@ -3730,11 +3753,12 @@ var __webpack_modules__ = {
3730
3753
  var _chalk = _interopRequireDefault(__webpack_require__("../../node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/index.js"));
3731
3754
  var _getType = __webpack_require__("../../node_modules/.pnpm/@jest+get-type@30.0.1/node_modules/@jest/get-type/build/index.js");
3732
3755
  var _prettyFormat = __webpack_require__("../../node_modules/.pnpm/pretty-format@30.0.2/node_modules/pretty-format/build/index.js");
3733
- var _cleanupSemantic = __nested_webpack_require_47190__("./src/cleanupSemantic.ts");
3734
- var _constants = __nested_webpack_require_47190__("./src/constants.ts");
3735
- var _diffLines = __nested_webpack_require_47190__("./src/diffLines.ts");
3736
- var _normalizeDiffOptions = __nested_webpack_require_47190__("./src/normalizeDiffOptions.ts");
3737
- var _printDiffs = __nested_webpack_require_47190__("./src/printDiffs.ts");
3756
+ var _cleanupSemantic = __nested_webpack_require_48295__("./src/cleanupSemantic.ts");
3757
+ var _constants = __nested_webpack_require_48295__("./src/constants.ts");
3758
+ var _diffLines = __nested_webpack_require_48295__("./src/diffLines.ts");
3759
+ var _escapeControlCharacters = __nested_webpack_require_48295__("./src/escapeControlCharacters.ts");
3760
+ var _normalizeDiffOptions = __nested_webpack_require_48295__("./src/normalizeDiffOptions.ts");
3761
+ var _printDiffs = __nested_webpack_require_48295__("./src/printDiffs.ts");
3738
3762
  function _interopRequireDefault(e) {
3739
3763
  return e && e.__esModule ? e : {
3740
3764
  default: e
@@ -3777,7 +3801,7 @@ var __webpack_modules__ = {
3777
3801
  if (omitDifference) return null;
3778
3802
  switch(aType){
3779
3803
  case 'string':
3780
- return (0, _diffLines.diffLinesUnified)(a.split('\n'), b.split('\n'), options);
3804
+ return (0, _diffLines.diffLinesUnified)((0, _escapeControlCharacters.escapeControlCharacters)(a).split('\n'), (0, _escapeControlCharacters.escapeControlCharacters)(b).split('\n'), options);
3781
3805
  case 'boolean':
3782
3806
  case 'number':
3783
3807
  return comparePrimitive(a, b, options);
@@ -4954,7 +4978,7 @@ var __webpack_modules__ = {
4954
4978
  o: ()=>formatTestError
4955
4979
  });
4956
4980
  var external_node_util_ = __webpack_require__("node:util");
4957
- var build = __webpack_require__("../../node_modules/.pnpm/jest-diff@30.0.2/node_modules/jest-diff/build/index.js");
4981
+ var build = __webpack_require__("../../node_modules/.pnpm/jest-diff@30.0.3/node_modules/jest-diff/build/index.js");
4958
4982
  build.DIFF_DELETE;
4959
4983
  build.DIFF_EQUAL;
4960
4984
  build.DIFF_INSERT;
@@ -5622,6 +5646,40 @@ const loadModule_createRequire = (filename, distPath, rstestContext, assetFiles,
5622
5646
  require1.main = _require.main;
5623
5647
  return require1;
5624
5648
  };
5649
+ const defineRstestDynamicImport = ({ testPath, interopDefault, returnModule = false })=>async (specifier, importAttributes)=>{
5650
+ const resolvedPath = isAbsolute(specifier) ? pathToFileURL(specifier) : await import.meta.resolve(specifier, pathToFileURL(testPath));
5651
+ const modulePath = 'string' == typeof resolvedPath ? resolvedPath : resolvedPath.pathname;
5652
+ if (importAttributes?.with?.rstest) delete importAttributes.with.rstest;
5653
+ const importedModule = await import(modulePath, importAttributes);
5654
+ if (shouldInterop({
5655
+ interopDefault,
5656
+ modulePath,
5657
+ mod: importedModule
5658
+ })) {
5659
+ const { mod, defaultExport } = interopModule(importedModule);
5660
+ if (returnModule) return asModule(mod, defaultExport);
5661
+ return new Proxy(mod, {
5662
+ get (mod, prop) {
5663
+ if ('default' === prop) return defaultExport;
5664
+ return mod[prop] ?? defaultExport?.[prop];
5665
+ },
5666
+ has (mod, prop) {
5667
+ if ('default' === prop) return void 0 !== defaultExport;
5668
+ return prop in mod || defaultExport && prop in defaultExport;
5669
+ },
5670
+ getOwnPropertyDescriptor (mod, prop) {
5671
+ const descriptor = Reflect.getOwnPropertyDescriptor(mod, prop);
5672
+ if (descriptor) return descriptor;
5673
+ if ('default' === prop && void 0 !== defaultExport) return {
5674
+ value: defaultExport,
5675
+ enumerable: true,
5676
+ configurable: true
5677
+ };
5678
+ }
5679
+ });
5680
+ }
5681
+ return importedModule;
5682
+ };
5625
5683
  const loadModule = ({ codeContent, distPath, testPath, rstestContext, assetFiles, interopDefault })=>{
5626
5684
  const fileDir = external_pathe_["default"].dirname(testPath);
5627
5685
  const localModule = {
@@ -5637,6 +5695,10 @@ const loadModule = ({ codeContent, distPath, testPath, rstestContext, assetFiles
5637
5695
  module: localModule,
5638
5696
  exports: localModule.exports,
5639
5697
  require: loadModule_createRequire(testPath, distPath, rstestContext, assetFiles, interopDefault),
5698
+ __rstest_dynamic_import__: defineRstestDynamicImport({
5699
+ testPath,
5700
+ interopDefault
5701
+ }),
5640
5702
  __dirname: fileDir,
5641
5703
  __filename: testPath,
5642
5704
  ...rstestContext
@@ -5647,20 +5709,11 @@ const loadModule = ({ codeContent, distPath, testPath, rstestContext, assetFiles
5647
5709
  filename: distPath,
5648
5710
  lineOffset: 0,
5649
5711
  columnOffset: -codeDefinition.length,
5650
- importModuleDynamically: async (specifier, _referencer, importAttributes)=>{
5651
- const resolvedPath = isAbsolute(specifier) ? pathToFileURL(specifier) : await import.meta.resolve(specifier, pathToFileURL(testPath));
5652
- const modulePath = 'string' == typeof resolvedPath ? resolvedPath : resolvedPath.pathname;
5653
- const importedModule = await import(modulePath, importAttributes);
5654
- if (shouldInterop({
5712
+ importModuleDynamically: (specifier, _referencer, importAttributes)=>defineRstestDynamicImport({
5713
+ testPath,
5655
5714
  interopDefault,
5656
- modulePath,
5657
- mod: importedModule
5658
- })) {
5659
- const { mod, defaultExport } = interopModule(importedModule);
5660
- return asModule(mod, defaultExport);
5661
- }
5662
- return importedModule;
5663
- }
5715
+ returnModule: true
5716
+ })(specifier, importAttributes)
5664
5717
  });
5665
5718
  fn(...Object.values(context));
5666
5719
  return localModule.exports;
@@ -5792,10 +5845,20 @@ const preparePool = async ({ entryInfo: { distPath, testPath }, sourceMaps, upda
5792
5845
  }
5793
5846
  };
5794
5847
  };
5795
- const loadFiles = async ({ setupEntries, assetFiles, rstestContext, distPath, testPath, interopDefault })=>{
5848
+ const loadFiles = async ({ setupEntries, assetFiles, rstestContext, distPath, testPath, interopDefault, isolate })=>{
5849
+ if (!isolate) await loadModule({
5850
+ codeContent: `if (global && typeof global.__rstest_clean_core_cache__ === 'function') {
5851
+ global.__rstest_clean_core_cache__();
5852
+ }`,
5853
+ distPath,
5854
+ testPath,
5855
+ rstestContext,
5856
+ assetFiles,
5857
+ interopDefault
5858
+ });
5796
5859
  for (const { distPath, testPath } of setupEntries){
5797
5860
  const setupCodeContent = assetFiles[distPath];
5798
- await cacheableLoadModule({
5861
+ await loadModule({
5799
5862
  codeContent: setupCodeContent,
5800
5863
  distPath,
5801
5864
  testPath,
@@ -5804,7 +5867,7 @@ const loadFiles = async ({ setupEntries, assetFiles, rstestContext, distPath, te
5804
5867
  interopDefault
5805
5868
  });
5806
5869
  }
5807
- await cacheableLoadModule({
5870
+ await loadModule({
5808
5871
  codeContent: assetFiles[distPath],
5809
5872
  distPath,
5810
5873
  testPath,
@@ -5814,7 +5877,7 @@ const loadFiles = async ({ setupEntries, assetFiles, rstestContext, distPath, te
5814
5877
  });
5815
5878
  };
5816
5879
  const runInPool = async (options)=>{
5817
- const { entryInfo: { distPath, testPath }, setupEntries, assetFiles, type } = options;
5880
+ const { entryInfo: { distPath, testPath }, setupEntries, assetFiles, type, context: { runtimeConfig: { isolate } } } = options;
5818
5881
  const cleanups = [];
5819
5882
  if ('collect' === type) try {
5820
5883
  const { rstestContext, runner, cleanup, unhandledErrors, interopDefault } = await preparePool(options);
@@ -5825,7 +5888,8 @@ const runInPool = async (options)=>{
5825
5888
  testPath,
5826
5889
  assetFiles,
5827
5890
  setupEntries,
5828
- interopDefault
5891
+ interopDefault,
5892
+ isolate
5829
5893
  });
5830
5894
  const tests = await runner.collectTests();
5831
5895
  return {
@@ -5842,7 +5906,11 @@ const runInPool = async (options)=>{
5842
5906
  } finally{
5843
5907
  await Promise.all(cleanups.map((fn)=>fn()));
5844
5908
  }
5909
+ const exit = process.exit;
5845
5910
  try {
5911
+ process.exit = (code = process.exitCode || 0)=>{
5912
+ throw new Error(`process.exit unexpectedly called with "${code}"`);
5913
+ };
5846
5914
  const { rstestContext, runner, rpc, api, cleanup, unhandledErrors, interopDefault } = await preparePool(options);
5847
5915
  cleanups.push(cleanup);
5848
5916
  await loadFiles({
@@ -5851,7 +5919,8 @@ const runInPool = async (options)=>{
5851
5919
  testPath,
5852
5920
  assetFiles,
5853
5921
  setupEntries,
5854
- interopDefault
5922
+ interopDefault,
5923
+ isolate
5855
5924
  });
5856
5925
  const results = await runner.runTests(testPath, {
5857
5926
  onTestFileStart: async (test)=>{
@@ -5879,6 +5948,7 @@ const runInPool = async (options)=>{
5879
5948
  };
5880
5949
  } finally{
5881
5950
  await Promise.all(cleanups.map((fn)=>fn()));
5951
+ process.exit = exit;
5882
5952
  }
5883
5953
  };
5884
5954
  const worker = runInPool;
@@ -79,7 +79,7 @@ declare type NormalizedConfig = Required<Omit<RstestConfig, OptionalKeys | 'pool
79
79
  pool: RstestPoolOptions;
80
80
  };
81
81
 
82
- declare type OptionalKeys = 'setupFiles' | 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'output' | 'tools' | 'onConsoleLog';
82
+ declare type OptionalKeys = 'setupFiles' | 'testNamePattern' | 'plugins' | 'source' | 'resolve' | 'output' | 'performance' | 'tools' | 'dev' | 'onConsoleLog';
83
83
 
84
84
  export declare interface Reporter {
85
85
  /**
@@ -120,6 +120,14 @@ declare const reportersMap: {
120
120
 
121
121
  declare type ReporterWithOptions<Name extends BuiltInReporterNames = BuiltInReporterNames> = Name extends keyof BuiltinReporterOptions ? [Name, Partial<BuiltinReporterOptions[Name]>] : [Name, Record<string, unknown>];
122
122
 
123
+ 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;
124
+
125
+ declare type RoArray<T> = Ro<T>[];
126
+
127
+ declare type RoObject<T> = {
128
+ [K in keyof T]: T[K] | Ro<T[K]>;
129
+ };
130
+
123
131
  export declare type RstestCommand = 'watch' | 'run' | 'list';
124
132
 
125
133
  export declare interface RstestConfig {
@@ -163,7 +171,7 @@ export declare interface RstestConfig {
163
171
  */
164
172
  retry?: number;
165
173
  /**
166
- * Allows the test suite to pass when no files are found.
174
+ * Pass when no tests are found.
167
175
  *
168
176
  * @default false
169
177
  */
@@ -263,7 +271,9 @@ export declare interface RstestConfig {
263
271
  onConsoleLog?: (content: string) => boolean | void;
264
272
  plugins?: RsbuildConfig['plugins'];
265
273
  source?: Pick<NonNullable<RsbuildConfig['source']>, 'define' | 'tsconfigPath' | 'decorators' | 'include' | 'exclude'>;
266
- output?: Pick<NonNullable<RsbuildConfig['output']>, 'cssModules'>;
274
+ performance?: Pick<NonNullable<RsbuildConfig['performance']>, 'bundleAnalyze'>;
275
+ dev?: Pick<NonNullable<RsbuildConfig['dev']>, 'writeToDisk'>;
276
+ output?: Pick<NonNullable<RsbuildConfig['output']>, 'cssModules' | 'externals' | 'cleanDistPath'>;
267
277
  resolve?: RsbuildConfig['resolve'];
268
278
  tools?: Pick<NonNullable<RsbuildConfig['tools']>, 'rspack' | 'swc' | 'bundlerChain'>;
269
279
  }
@@ -312,11 +322,11 @@ declare interface SourceMapV3 {
312
322
 
313
323
  declare type SourcesIndex = number;
314
324
 
315
- declare type TestFileInfo = {
325
+ export declare type TestFileInfo = {
316
326
  testPath: TestPath;
317
327
  };
318
328
 
319
- declare type TestFileResult = TestResult & {
329
+ export declare type TestFileResult = TestResult & {
320
330
  results: TestResult[];
321
331
  snapshotResult?: SnapshotResult;
322
332
  };
@@ -324,13 +334,14 @@ declare type TestFileResult = TestResult & {
324
334
  /** The test file original path */
325
335
  declare type TestPath = string;
326
336
 
327
- declare type TestResult = {
337
+ export declare type TestResult = {
328
338
  status: TestResultStatus;
329
339
  name: string;
330
340
  testPath: TestPath;
331
341
  parentNames?: string[];
332
342
  duration?: number;
333
343
  errors?: FormattedError[];
344
+ retryCount?: number;
334
345
  };
335
346
 
336
347
  declare type TestResultStatus = 'skip' | 'pass' | 'fail' | 'todo';
@@ -349,7 +360,7 @@ declare class TraceMap implements SourceMap {
349
360
  private _decodedMemo;
350
361
  private _bySources;
351
362
  private _bySourceMemos;
352
- constructor(map: SourceMapInput, mapUrl?: string | null);
363
+ constructor(map: Ro<SourceMapInput>, mapUrl?: string | null);
353
364
  }
354
365
 
355
366
  declare interface UserConsoleLog {