@rstest/core 0.5.4 → 0.6.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.
package/LICENSE.md CHANGED
@@ -682,7 +682,7 @@ Licensed under MIT license in the repository at chalk/ansi-styles.
682
682
 
683
683
  ### birpc
684
684
 
685
- Licensed under MIT license in the repository at git+https://github.com/antfu/birpc.git.
685
+ Licensed under MIT license in the repository at git+https://github.com/antfu-collective/birpc.git.
686
686
 
687
687
  > MIT License
688
688
  >
@@ -5,9 +5,9 @@ import * as __WEBPACK_EXTERNAL_MODULE_node_v8_d0df5498__ from "node:v8";
5
5
  import * as __WEBPACK_EXTERNAL_MODULE_node_events_0a6aefe7__ from "node:events";
6
6
  import * as __WEBPACK_EXTERNAL_MODULE_tinypool__ from "tinypool";
7
7
  import * as __WEBPACK_EXTERNAL_MODULE_node_inspector_dd9822d6__ from "node:inspector";
8
- export const __webpack_id__ = "816";
8
+ export const __webpack_id__ = "628";
9
9
  export const __webpack_ids__ = [
10
- "816"
10
+ "628"
11
11
  ];
12
12
  export const __webpack_modules__ = {
13
13
  "./src/core/rsbuild.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
@@ -15,6 +15,7 @@ export const __webpack_modules__ = {
15
15
  XD: ()=>createRsbuildServer,
16
16
  zh: ()=>prepareRsbuild
17
17
  });
18
+ var external_node_url_ = __webpack_require__("node:url");
18
19
  var core_ = __webpack_require__("@rsbuild/core");
19
20
  var dist = __webpack_require__("../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/index.mjs");
20
21
  var utils = __webpack_require__("./src/utils/index.ts");
@@ -56,6 +57,7 @@ export const __webpack_modules__ = {
56
57
  config.output.iife = false;
57
58
  config.output.importFunctionName = '__rstest_dynamic_import__';
58
59
  config.output.devtoolModuleFilenameTemplate = '[absolute-resource-path]';
60
+ if (!config.devtool || !config.devtool.includes('inline')) config.devtool = 'nosources-source-map';
59
61
  config.plugins.push(new rspack.experiments.RstestPlugin({
60
62
  injectModulePathName: true,
61
63
  importMetaPathName: true,
@@ -108,7 +110,6 @@ export const __webpack_modules__ = {
108
110
  }
109
111
  });
110
112
  var external_node_path_ = __webpack_require__("node:path");
111
- var external_node_url_ = __webpack_require__("node:url");
112
113
  const PLUGIN_CSS_FILTER = 'rstest:css-filter';
113
114
  const css_filter_dirname = external_node_path_["default"].dirname((0, external_node_url_.fileURLToPath)(import.meta.url));
114
115
  const pluginCSSFilter = ()=>({
@@ -258,7 +259,7 @@ export const __webpack_modules__ = {
258
259
  name: 'rstest:inspect',
259
260
  setup: (api)=>{
260
261
  api.modifyRspackConfig(async (config)=>{
261
- config.devtool = 'inline-source-map';
262
+ config.devtool = 'inline-nosources-source-map';
262
263
  config.optimization ??= {};
263
264
  config.optimization.splitChunks = {
264
265
  ...config.optimization.splitChunks || {},
@@ -268,6 +269,8 @@ export const __webpack_modules__ = {
268
269
  });
269
270
  }
270
271
  } : null;
272
+ var external_node_fs_ = __webpack_require__("node:fs");
273
+ const mockRuntime_dirname = external_node_path_["default"].dirname((0, external_node_url_.fileURLToPath)(import.meta.url));
271
274
  class MockRuntimeRspackPlugin {
272
275
  apply(compiler) {
273
276
  const { RuntimeModule } = compiler.webpack;
@@ -276,109 +279,24 @@ export const __webpack_modules__ = {
276
279
  super('rstest runtime');
277
280
  }
278
281
  generate() {
279
- return `
280
- if (typeof __webpack_require__ === 'undefined') {
281
- return;
282
- }
283
-
284
- const originalRequire = __webpack_require__;
285
- __webpack_require__ = function(...args) {
286
- try {
287
- return originalRequire(...args);
288
- } catch (e) {
289
- const errMsg = e.message ?? e.toString();
290
- if (errMsg.includes('__webpack_modules__[moduleId] is not a function')) {
291
- throw new Error(\`Cannot find module '\${args[0]}'\`)
292
- }
293
- throw e;
294
- }
295
- };
296
-
297
- Object.keys(originalRequire).forEach(key => {
298
- __webpack_require__[key] = originalRequire[key];
299
- });
300
-
301
- __webpack_require__.rstest_original_modules = {};
302
-
303
- __webpack_require__.rstest_reset_modules = () => {
304
- const mockedIds = Object.keys(__webpack_require__.rstest_original_modules)
305
- Object.keys(__webpack_module_cache__).forEach(id => {
306
- // Do not reset mocks registry.
307
- if (!mockedIds.includes(id)) {
308
- delete __webpack_module_cache__[id];
309
- }
310
- });
311
- }
312
-
313
- __webpack_require__.rstest_unmock = (id) => {
314
- delete __webpack_module_cache__[id]
315
- }
316
-
317
- __webpack_require__.rstest_require_actual = __webpack_require__.rstest_import_actual = (id) => {
318
- const originalModule = __webpack_require__.rstest_original_modules[id];
319
- // Use fallback module if the module is not mocked.
320
- const fallbackMod = __webpack_require__(id);
321
- return originalModule ? originalModule : fallbackMod;
322
- }
323
-
324
- __webpack_require__.rstest_exec = async (id, modFactory) => {
325
- if (__webpack_module_cache__) {
326
- let asyncFactory = __webpack_module_cache__[id];
327
- if (asyncFactory && asyncFactory.constructor.name === 'AsyncFunction') {
328
- await asyncFactory();
329
- }
330
- }
331
- };
332
-
333
- __webpack_require__.rstest_mock = (id, modFactory) => {
334
- let requiredModule = undefined
335
- try {
336
- requiredModule = __webpack_require__(id);
337
- } catch {
338
- // TODO: non-resolved module
339
- } finally {
340
- __webpack_require__.rstest_original_modules[id] = requiredModule;
341
- }
342
- if (typeof modFactory === 'string' || typeof modFactory === 'number') {
343
- __webpack_module_cache__[id] = { exports: __webpack_require__(modFactory) };
344
- } else if (typeof modFactory === 'function') {
345
- if (modFactory.constructor.name === 'AsyncFunction') {
346
- __webpack_module_cache__[id] = async () => {
347
- const exports = await modFactory();
348
- __webpack_require__.r(exports);
349
- __webpack_module_cache__[id] = { exports, id, loaded: true };
350
- }
351
- } else {
352
- const exports = modFactory();
353
- __webpack_require__.r(exports);
354
- __webpack_module_cache__[id] = { exports, id, loaded: true };
355
- }
356
- }
357
- };
358
-
359
- __webpack_require__.rstest_do_mock = (id, modFactory) => {
360
- let requiredModule = undefined
361
- try {
362
- requiredModule = __webpack_require__(id);
363
- } catch {
364
- // TODO: non-resolved module
365
- } finally {
366
- __webpack_require__.rstest_original_modules[id] = requiredModule;
367
- }
368
- if (typeof modFactory === 'string' || typeof modFactory === 'number') {
369
- __webpack_module_cache__[id] = { exports: __webpack_require__(modFactory) };
370
- } else if (typeof modFactory === 'function') {
371
- const exports = modFactory();
372
- __webpack_require__.r(exports);
373
- __webpack_module_cache__[id] = { exports, id, loaded: true };
374
- }
375
- };
376
-
377
- `;
282
+ const code = external_node_fs_["default"].readFileSync(external_node_path_["default"].join(mockRuntime_dirname, './mockRuntimeCode.js'), 'utf8');
283
+ return code;
378
284
  }
379
285
  }
380
- compiler.hooks.thisCompilation.tap('CustomPlugin', (compilation)=>{
381
- compilation.hooks.additionalTreeRuntimeRequirements.tap('CustomPlugin', (chunk)=>{
286
+ compiler.hooks.compilation.tap('RstestMockPlugin', (compilation)=>{
287
+ compilation.hooks.runtimeModule.tap('RstestMockChunkLoadingRuntimePlugin', (module)=>{
288
+ if ('require_chunk_loading' === module.name) {
289
+ const finalSource = module.source.source.toString('utf-8').replace('for (var moduleId in moreModules) {', "for (var moduleId in moreModules) {\n if (Object.keys(__webpack_require__.rstest_original_modules).includes(moduleId)) continue;");
290
+ module.source.source = Buffer.from(finalSource);
291
+ }
292
+ if ('define_property_getters' === module.name) {
293
+ const finalSource = module.source.source.toString('utf-8').replace('enumerable: true, get:', 'enumerable: true, configurable: true, get:');
294
+ module.source.source = Buffer.from(finalSource);
295
+ }
296
+ });
297
+ });
298
+ compiler.hooks.thisCompilation.tap('RstestMockPlugin', (compilation)=>{
299
+ compilation.hooks.additionalTreeRuntimeRequirements.tap('RstestAddMockRuntimePlugin', (chunk)=>{
382
300
  compilation.addRuntimeModule(chunk, new RetestImportRuntimeModule());
383
301
  });
384
302
  });
@@ -418,8 +336,8 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
418
336
  `;
419
337
  }
420
338
  }
421
- compiler.hooks.thisCompilation.tap('CustomPlugin', (compilation)=>{
422
- compilation.hooks.additionalTreeRuntimeRequirements.tap('CustomPlugin', (chunk)=>{
339
+ compiler.hooks.thisCompilation.tap('RstestCacheControlPlugin', (compilation)=>{
340
+ compilation.hooks.additionalTreeRuntimeRequirements.tap('RstestAddCacheControlRuntimePlugin', (chunk)=>{
423
341
  compilation.addRuntimeModule(chunk, new RetestCacheControlModule());
424
342
  });
425
343
  });
@@ -443,6 +361,7 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
443
361
  });
444
362
  }
445
363
  });
364
+ const rsbuild_dirname = dist.Ay.dirname((0, external_node_url_.fileURLToPath)(import.meta.url));
446
365
  function parseInlineSourceMapStr(code) {
447
366
  const inlineSourceMapRegex = /\/\/# sourceMappingURL=data:application\/json(?:;charset=utf-8)?;base64,(.+)\s*$/m;
448
367
  const match = code.match(inlineSourceMapRegex);
@@ -574,6 +493,11 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
574
493
  const rstestCompilerPlugin = {
575
494
  name: 'rstest:compiler',
576
495
  setup: (api)=>{
496
+ api.modifyBundlerChain((chain)=>{
497
+ chain.module.rule('rstest-mock-module-doppelgangers').test(/\.(?:js|jsx|mjs|cjs|ts|tsx|mts|cts)$/).with({
498
+ rstest: 'importActual'
499
+ }).use('import-actual-loader').loader(dist.Ay.resolve(rsbuild_dirname, './importActualLoader.mjs')).end();
500
+ });
577
501
  api.onAfterCreateCompiler(({ compiler })=>{
578
502
  rspackCompiler = compiler;
579
503
  });
@@ -840,7 +764,7 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
840
764
  if (msg.t === TYPE_REQUEST) {
841
765
  const { m: method, a: args } = msg;
842
766
  let result, error;
843
- const fn = resolver ? resolver(method, functions[method]) : functions[method];
767
+ const fn = await (resolver ? resolver(method, functions[method]) : functions[method]);
844
768
  if (fn) try {
845
769
  result = await fn.apply("rpc" === bind ? rpc : functions, args);
846
770
  } catch (e) {
@@ -1060,11 +984,12 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
1060
984
  const projectName = context.normalizedConfig.name;
1061
985
  const runtimeConfig = getRuntimeConfig(project);
1062
986
  const setupAssets = setupEntries.flatMap((entry)=>entry.files || []);
1063
- const results = await Promise.all(entries.map(async (entryInfo)=>{
987
+ const results = await Promise.all(entries.map(async (entryInfo, index)=>{
1064
988
  const result = await pool.runTest({
1065
989
  options: {
1066
990
  entryInfo,
1067
991
  context: {
992
+ taskId: index + 1,
1068
993
  project: projectName,
1069
994
  rootPath: context.rootPath,
1070
995
  projectRoot: project.rootPath,
@@ -1107,10 +1032,11 @@ global.__rstest_clean_core_cache__ = __rstest_clean_core_cache__;
1107
1032
  const runtimeConfig = getRuntimeConfig(project);
1108
1033
  const projectName = project.normalizedConfig.name;
1109
1034
  const setupAssets = setupEntries.flatMap((entry)=>entry.files || []);
1110
- return Promise.all(entries.map(async (entryInfo)=>pool.collectTests({
1035
+ return Promise.all(entries.map(async (entryInfo, index)=>pool.collectTests({
1111
1036
  options: {
1112
1037
  entryInfo,
1113
1038
  context: {
1039
+ taskId: index + 1,
1114
1040
  project: projectName,
1115
1041
  rootPath: context.rootPath,
1116
1042
  projectRoot: project.rootPath,
package/dist/0~655.js CHANGED
@@ -1541,7 +1541,7 @@ export const __webpack_modules__ = {
1541
1541
  const string = `${options.stylize(helpers_truncate(array[i], options.truncate), 'number')}${i === array.length - 1 ? '' : ', '}`;
1542
1542
  options.truncate -= string.length;
1543
1543
  if (array[i] !== array.length && options.truncate <= 3) {
1544
- output += `${truncator}(${array.length - array[i] + 1})`;
1544
+ output += `…(${array.length - array[i] + 1})`;
1545
1545
  break;
1546
1546
  }
1547
1547
  output += string;
@@ -1598,7 +1598,7 @@ export const __webpack_modules__ = {
1598
1598
  }
1599
1599
  function inspectBigInt(number, options) {
1600
1600
  let nums = helpers_truncate(number.toString(), options.truncate - 1);
1601
- if (nums !== truncator) nums += 'n';
1601
+ if ("…" !== nums) nums += 'n';
1602
1602
  return options.stylize(nums, 'bigint');
1603
1603
  }
1604
1604
  function inspectRegExp(value, options) {
@@ -1754,7 +1754,7 @@ export const __webpack_modules__ = {
1754
1754
  options.truncate -= propertyContents.length;
1755
1755
  const truncate = options.truncate;
1756
1756
  let children = inspectNodeCollection(element.children, options);
1757
- if (children && children.length > truncate) children = `${truncator}(${element.children.length})`;
1757
+ if (children && children.length > truncate) children = `…(${element.children.length})`;
1758
1758
  return `${head}${propertyContents}${headClose}${children}${tail}`;
1759
1759
  }
1760
1760
  const symbolsSupported = 'function' == typeof Symbol && 'function' == typeof Symbol.for;
@@ -3285,7 +3285,7 @@ export const __webpack_modules__ = {
3285
3285
  function getCommonAndChangedSubstrings(diffs, op, hasCommonDiff) {
3286
3286
  return diffs.reduce((reduced, diff)=>reduced + (diff[0] === DIFF_EQUAL ? diff[1] : diff[0] === op ? hasCommonDiff ? dist_node.Ay.inverse(diff[1]) : diff[1] : ""), "");
3287
3287
  }
3288
- __webpack_require__("../../node_modules/.pnpm/tinyspy@4.0.3/node_modules/tinyspy/dist/index.js");
3288
+ __webpack_require__("../../node_modules/.pnpm/tinyspy@4.0.4/node_modules/tinyspy/dist/index.js");
3289
3289
  new Set();
3290
3290
  function isMockFunction(fn) {
3291
3291
  return "function" == typeof fn && "_isMockFunction" in fn && fn._isMockFunction;
@@ -11369,165 +11369,165 @@ deep-eql/index.js:
11369
11369
  var node_r = void 0 !== process.env.FORCE_TTY || (0, external_node_tty_.isatty)(1);
11370
11370
  var node_u = p(node_r);
11371
11371
  },
11372
- "../../node_modules/.pnpm/tinyspy@4.0.3/node_modules/tinyspy/dist/index.js": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
11372
+ "../../node_modules/.pnpm/tinyspy@4.0.4/node_modules/tinyspy/dist/index.js": function(__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
11373
11373
  __webpack_require__.d(__webpack_exports__, {
11374
- jo: ()=>internalSpyOn,
11375
- lf: ()=>getInternalState
11374
+ jo: ()=>M,
11375
+ lf: ()=>T
11376
11376
  });
11377
- function assert(condition, message) {
11378
- if (!condition) throw new Error(message);
11377
+ function S(e, t) {
11378
+ if (!e) throw new Error(t);
11379
11379
  }
11380
- function isType(type, value) {
11381
- return typeof value === type;
11380
+ function f(e, t) {
11381
+ return typeof t === e;
11382
11382
  }
11383
- function isPromise(value) {
11384
- return value instanceof Promise;
11383
+ function w(e) {
11384
+ return e instanceof Promise;
11385
11385
  }
11386
- function define(obj, key, descriptor) {
11387
- Object.defineProperty(obj, key, descriptor);
11386
+ function u(e, t, r) {
11387
+ Object.defineProperty(e, t, r);
11388
11388
  }
11389
- function defineValue(obj, key, value) {
11390
- define(obj, key, {
11391
- value,
11389
+ function l(e, t, r) {
11390
+ u(e, t, {
11391
+ value: r,
11392
11392
  configurable: !0,
11393
11393
  writable: !0
11394
11394
  });
11395
11395
  }
11396
- var SYMBOL_STATE = Symbol.for("tinyspy:spy");
11397
- var spies = /* @__PURE__ */ new Set(), reset = (state)=>{
11398
- state.called = !1, state.callCount = 0, state.calls = [], state.results = [], state.resolves = [], state.next = [];
11399
- }, defineState = (spy2)=>(define(spy2, SYMBOL_STATE, {
11396
+ var y = Symbol.for("tinyspy:spy");
11397
+ var x = /* @__PURE__ */ new Set(), h = (e)=>{
11398
+ e.called = !1, e.callCount = 0, e.calls = [], e.results = [], e.resolves = [], e.next = [];
11399
+ }, k = (e)=>(u(e, y, {
11400
11400
  value: {
11401
- reset: ()=>reset(spy2[SYMBOL_STATE])
11402
- }
11403
- }), spy2[SYMBOL_STATE]), getInternalState = (spy2)=>spy2[SYMBOL_STATE] || defineState(spy2);
11404
- function createInternalSpy(cb) {
11405
- assert(isType("function", cb) || isType("undefined", cb), "cannot spy on a non-function value");
11406
- let fn = function(...args) {
11407
- let state2 = getInternalState(fn);
11408
- state2.called = !0, state2.callCount++, state2.calls.push(args);
11409
- let next = state2.next.shift();
11410
- if (next) {
11411
- state2.results.push(next);
11412
- let [type2, result2] = next;
11413
- if ("ok" === type2) return result2;
11414
- throw result2;
11415
- }
11416
- let result, type = "ok", resultIndex = state2.results.length;
11417
- if (state2.impl) try {
11418
- new.target ? result = Reflect.construct(state2.impl, args, new.target) : result = state2.impl.apply(this, args), type = "ok";
11419
- } catch (err) {
11420
- throw result = err, type = "error", state2.results.push([
11421
- type,
11422
- err
11423
- ]), err;
11424
- }
11425
- let resultTuple = [
11426
- type,
11427
- result
11401
+ reset: ()=>h(e[y])
11402
+ }
11403
+ }), e[y]), T = (e)=>e[y] || k(e);
11404
+ function R(e) {
11405
+ S(f("function", e) || f("undefined", e), "cannot spy on a non-function value");
11406
+ let t = function(...s) {
11407
+ let n = T(t);
11408
+ n.called = !0, n.callCount++, n.calls.push(s);
11409
+ let d = n.next.shift();
11410
+ if (d) {
11411
+ n.results.push(d);
11412
+ let [a, i] = d;
11413
+ if ("ok" === a) return i;
11414
+ throw i;
11415
+ }
11416
+ let o, c = "ok", p = n.results.length;
11417
+ if (n.impl) try {
11418
+ new.target ? o = Reflect.construct(n.impl, s, new.target) : o = n.impl.apply(this, s), c = "ok";
11419
+ } catch (a) {
11420
+ throw o = a, c = "error", n.results.push([
11421
+ c,
11422
+ a
11423
+ ]), a;
11424
+ }
11425
+ let g = [
11426
+ c,
11427
+ o
11428
11428
  ];
11429
- return isPromise(result) && result.then((r)=>state2.resolves[resultIndex] = [
11429
+ return w(o) && o.then((a)=>n.resolves[p] = [
11430
11430
  "ok",
11431
- r
11432
- ], (e)=>state2.resolves[resultIndex] = [
11431
+ a
11432
+ ], (a)=>n.resolves[p] = [
11433
11433
  "error",
11434
- e
11435
- ]), state2.results.push(resultTuple), result;
11434
+ a
11435
+ ]), n.results.push(g), o;
11436
11436
  };
11437
- defineValue(fn, "_isMockFunction", !0), defineValue(fn, "length", cb ? cb.length : 0), defineValue(fn, "name", cb && cb.name || "spy");
11438
- let state = getInternalState(fn);
11439
- return state.reset(), state.impl = cb, fn;
11440
- }
11441
- function isMockFunction(obj) {
11442
- return !!obj && !0 === obj._isMockFunction;
11443
- }
11444
- var getDescriptor = (obj, method)=>{
11445
- let objDescriptor = Object.getOwnPropertyDescriptor(obj, method);
11446
- if (objDescriptor) return [
11447
- obj,
11448
- objDescriptor
11437
+ l(t, "_isMockFunction", !0), l(t, "length", e ? e.length : 0), l(t, "name", e && e.name || "spy");
11438
+ let r = T(t);
11439
+ return r.reset(), r.impl = e, t;
11440
+ }
11441
+ function v(e) {
11442
+ return !!e && !0 === e._isMockFunction;
11443
+ }
11444
+ var b = (e, t)=>{
11445
+ let r = Object.getOwnPropertyDescriptor(e, t);
11446
+ if (r) return [
11447
+ e,
11448
+ r
11449
11449
  ];
11450
- let currentProto = Object.getPrototypeOf(obj);
11451
- for(; null !== currentProto;){
11452
- let descriptor = Object.getOwnPropertyDescriptor(currentProto, method);
11453
- if (descriptor) return [
11454
- currentProto,
11455
- descriptor
11450
+ let s = Object.getPrototypeOf(e);
11451
+ for(; null !== s;){
11452
+ let n = Object.getOwnPropertyDescriptor(s, t);
11453
+ if (n) return [
11454
+ s,
11455
+ n
11456
11456
  ];
11457
- currentProto = Object.getPrototypeOf(currentProto);
11457
+ s = Object.getPrototypeOf(s);
11458
11458
  }
11459
- }, setPototype = (fn, val)=>{
11460
- null != val && "function" == typeof val && null != val.prototype && Object.setPrototypeOf(fn.prototype, val.prototype);
11459
+ }, P = (e, t)=>{
11460
+ null != t && "function" == typeof t && null != t.prototype && Object.setPrototypeOf(e.prototype, t.prototype);
11461
11461
  };
11462
- function internalSpyOn(obj, methodName, mock) {
11463
- assert(!isType("undefined", obj), "spyOn could not find an object to spy upon"), assert(isType("object", obj) || isType("function", obj), "cannot spyOn on a primitive value");
11464
- let [accessName, accessType] = (()=>{
11465
- if (!isType("object", methodName)) return [
11466
- methodName,
11462
+ function M(e, t, r) {
11463
+ S(!f("undefined", e), "spyOn could not find an object to spy upon"), S(f("object", e) || f("function", e), "cannot spyOn on a primitive value");
11464
+ let [s, n] = (()=>{
11465
+ if (!f("object", t)) return [
11466
+ t,
11467
11467
  "value"
11468
11468
  ];
11469
- if ("getter" in methodName && "setter" in methodName) throw new Error("cannot spy on both getter and setter");
11470
- if ("getter" in methodName) return [
11471
- methodName.getter,
11469
+ if ("getter" in t && "setter" in t) throw new Error("cannot spy on both getter and setter");
11470
+ if ("getter" in t) return [
11471
+ t.getter,
11472
11472
  "get"
11473
11473
  ];
11474
- if ("setter" in methodName) return [
11475
- methodName.setter,
11474
+ if ("setter" in t) return [
11475
+ t.setter,
11476
11476
  "set"
11477
11477
  ];
11478
11478
  throw new Error("specify getter or setter to spy on");
11479
- })(), [originalDescriptorObject, originalDescriptor] = getDescriptor(obj, accessName) || [];
11480
- assert(originalDescriptor || accessName in obj, `${String(accessName)} does not exist`);
11481
- let ssr = !1;
11482
- "value" === accessType && originalDescriptor && !originalDescriptor.value && originalDescriptor.get && (accessType = "get", ssr = !0, mock = originalDescriptor.get());
11483
- let original;
11484
- originalDescriptor ? original = originalDescriptor[accessType] : "value" !== accessType ? original = ()=>obj[accessName] : original = obj[accessName], original && isSpyFunction(original) && (original = original[SYMBOL_STATE].getOriginal());
11485
- let reassign = (cb)=>{
11486
- let { value, ...desc } = originalDescriptor || {
11479
+ })(), [d, o] = b(e, s) || [];
11480
+ S(o || s in e, `${String(s)} does not exist`);
11481
+ let c = !1;
11482
+ "value" === n && o && !o.value && o.get && (n = "get", c = !0, r = o.get());
11483
+ let p;
11484
+ o ? p = o[n] : "value" !== n ? p = ()=>e[s] : p = e[s], p && j(p) && (p = p[y].getOriginal());
11485
+ let g = (I)=>{
11486
+ let { value: F, ...O } = o || {
11487
11487
  configurable: !0,
11488
11488
  writable: !0
11489
11489
  };
11490
- "value" !== accessType && delete desc.writable, desc[accessType] = cb, define(obj, accessName, desc);
11491
- }, restore = ()=>{
11492
- originalDescriptorObject !== obj ? Reflect.deleteProperty(obj, accessName) : originalDescriptor && !original ? define(obj, accessName, originalDescriptor) : reassign(original);
11490
+ "value" !== n && delete O.writable, O[n] = I, u(e, s, O);
11491
+ }, a = ()=>{
11492
+ d !== e ? Reflect.deleteProperty(e, s) : o && !p ? u(e, s, o) : g(p);
11493
11493
  };
11494
- mock || (mock = original);
11495
- let spy2 = wrap(createInternalSpy(mock), mock);
11496
- "value" === accessType && setPototype(spy2, original);
11497
- let state = spy2[SYMBOL_STATE];
11498
- return defineValue(state, "restore", restore), defineValue(state, "getOriginal", ()=>ssr ? original() : original), defineValue(state, "willCall", (newCb)=>(state.impl = newCb, spy2)), reassign(ssr ? ()=>(setPototype(spy2, mock), spy2) : spy2), spies.add(spy2), spy2;
11494
+ r || (r = p);
11495
+ let i = E(R(r), r);
11496
+ "value" === n && P(i, p);
11497
+ let m = i[y];
11498
+ return l(m, "restore", a), l(m, "getOriginal", ()=>c ? p() : p), l(m, "willCall", (I)=>(m.impl = I, i)), g(c ? ()=>(P(i, r), i) : i), x.add(i), i;
11499
11499
  }
11500
- var ignoreProperties = /* @__PURE__ */ new Set([
11500
+ var K = /* @__PURE__ */ new Set([
11501
11501
  "length",
11502
11502
  "name",
11503
11503
  "prototype"
11504
11504
  ]);
11505
- function getAllProperties(original) {
11506
- let properties = /* @__PURE__ */ new Set(), descriptors2 = {};
11507
- for(; original && original !== Object.prototype && original !== Function.prototype;){
11508
- let ownProperties = [
11509
- ...Object.getOwnPropertyNames(original),
11510
- ...Object.getOwnPropertySymbols(original)
11505
+ function D(e) {
11506
+ let t = /* @__PURE__ */ new Set(), r = {};
11507
+ for(; e && e !== Object.prototype && e !== Function.prototype;){
11508
+ let s = [
11509
+ ...Object.getOwnPropertyNames(e),
11510
+ ...Object.getOwnPropertySymbols(e)
11511
11511
  ];
11512
- for (let prop of ownProperties)descriptors2[prop] || ignoreProperties.has(prop) || (properties.add(prop), descriptors2[prop] = Object.getOwnPropertyDescriptor(original, prop));
11513
- original = Object.getPrototypeOf(original);
11512
+ for (let n of s)r[n] || K.has(n) || (t.add(n), r[n] = Object.getOwnPropertyDescriptor(e, n));
11513
+ e = Object.getPrototypeOf(e);
11514
11514
  }
11515
11515
  return {
11516
- properties,
11517
- descriptors: descriptors2
11516
+ properties: t,
11517
+ descriptors: r
11518
11518
  };
11519
11519
  }
11520
- function wrap(mock, original) {
11521
- if (!original || SYMBOL_STATE in original) return mock;
11522
- let { properties, descriptors: descriptors2 } = getAllProperties(original);
11523
- for (let key of properties){
11524
- let descriptor = descriptors2[key];
11525
- getDescriptor(mock, key) || define(mock, key, descriptor);
11520
+ function E(e, t) {
11521
+ if (!t || y in t) return e;
11522
+ let { properties: r, descriptors: s } = D(t);
11523
+ for (let n of r){
11524
+ let d = s[n];
11525
+ b(e, n) || u(e, n, d);
11526
11526
  }
11527
- return mock;
11527
+ return e;
11528
11528
  }
11529
- function isSpyFunction(obj) {
11530
- return isMockFunction(obj) && "getOriginal" in obj[SYMBOL_STATE];
11529
+ function j(e) {
11530
+ return v(e) && "getOriginal" in e[y];
11531
11531
  }
11532
11532
  }
11533
11533
  };
package/dist/0~85.js CHANGED
@@ -1511,7 +1511,7 @@ export const __webpack_modules__ = {
1511
1511
  return this._fakingTime;
1512
1512
  }
1513
1513
  }
1514
- var tinyspy_dist = __webpack_require__("../../node_modules/.pnpm/tinyspy@4.0.3/node_modules/tinyspy/dist/index.js");
1514
+ var tinyspy_dist = __webpack_require__("../../node_modules/.pnpm/tinyspy@4.0.4/node_modules/tinyspy/dist/index.js");
1515
1515
  let callOrder = 0;
1516
1516
  const mocks = new Set();
1517
1517
  const wrapSpy = (obj, methodName, mockFn)=>{
@@ -0,0 +1 @@
1
+ export default ((source)=>source);
package/dist/index.js CHANGED
@@ -2108,7 +2108,7 @@ ${section.body}` : section.body).join("\n\n"));
2108
2108
  function setupCommands() {
2109
2109
  const cli = dist('rstest');
2110
2110
  cli.help();
2111
- cli.version("0.5.4");
2111
+ cli.version("0.6.1");
2112
2112
  applyCommonOptions(cli);
2113
2113
  cli.command('[...filters]', 'run tests').option('-w, --watch', 'Run tests in watch mode').action(async (filters, options)=>{
2114
2114
  (0, prepare.N)();
@@ -2282,12 +2282,13 @@ ${section.body}` : section.body).join("\n\n"));
2282
2282
  projectPaths.push(...await globProjects(projectPatterns));
2283
2283
  const projects = await Promise.all(projectPaths.map(async (project)=>{
2284
2284
  const isDirectory = (0, external_node_fs_.statSync)(project).isDirectory();
2285
+ const root = isDirectory ? project : (0, pathe_M_eThtNZ.d)(project);
2285
2286
  const { config, configFilePath } = await resolveConfig({
2286
2287
  ...options,
2287
2288
  config: isDirectory ? void 0 : project,
2288
- root: isDirectory ? project : (0, pathe_M_eThtNZ.d)(project)
2289
+ root
2289
2290
  });
2290
- config.name ??= getDefaultProjectName(project);
2291
+ config.name ??= getDefaultProjectName(root);
2291
2292
  if (config.projects?.length && config.root !== root) utils.vF.warn(`Projects cannot have nested projects, the "projects" field in project "${config.name}" will be ignored.`);
2292
2293
  return {
2293
2294
  config,
@@ -2348,7 +2349,7 @@ ${conflictProjects.map((p)=>`- ${p.configFilePath || p.config.root}`).join('\n')
2348
2349
  if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) console.log();
2349
2350
  }
2350
2351
  function showRstest() {
2351
- _utils_logger__WEBPACK_IMPORTED_MODULE_0__.vF.greet(" Rstest v0.5.4");
2352
+ _utils_logger__WEBPACK_IMPORTED_MODULE_0__.vF.greet(" Rstest v0.6.1");
2352
2353
  _utils_logger__WEBPACK_IMPORTED_MODULE_0__.vF.log('');
2353
2354
  }
2354
2355
  },
@@ -3275,7 +3276,7 @@ ${conflictProjects.map((p)=>`- ${p.configFilePath || p.config.root}`).join('\n')
3275
3276
  logs.push(`::${type} file=${this.onWritePath?.(file) || file},line=${line},col=${column},title=${escapeData(title)}::${escapeData(message)}`);
3276
3277
  }
3277
3278
  }
3278
- this.log('::group::error for github actions');
3279
+ this.log('::group::Error for GitHub Actions');
3279
3280
  for (const log of logs)this.log(log);
3280
3281
  this.log('::endgroup::');
3281
3282
  }
@@ -3468,7 +3469,7 @@ ${conflictProjects.map((p)=>`- ${p.configFilePath || p.config.root}`).join('\n')
3468
3469
  });
3469
3470
  this.reporters = reporters;
3470
3471
  this.snapshotManager = snapshotManager;
3471
- this.version = "0.5.4";
3472
+ this.version = "0.6.1";
3472
3473
  this.rootPath = rootPath;
3473
3474
  this.originalConfig = userConfig;
3474
3475
  this.normalizedConfig = rstestConfig;
@@ -3552,14 +3553,14 @@ ${conflictProjects.map((p)=>`- ${p.configFilePath || p.config.root}`).join('\n')
3552
3553
  }, config);
3553
3554
  const runTests = async ()=>{
3554
3555
  const { runTests } = await Promise.all([
3555
- __webpack_require__.e("816"),
3556
+ __webpack_require__.e("628"),
3556
3557
  __webpack_require__.e("33")
3557
3558
  ]).then(__webpack_require__.bind(__webpack_require__, "./src/core/runTests.ts"));
3558
3559
  await runTests(context);
3559
3560
  };
3560
3561
  const listTests = async (options)=>{
3561
3562
  const { listTests } = await Promise.all([
3562
- __webpack_require__.e("816"),
3563
+ __webpack_require__.e("628"),
3563
3564
  __webpack_require__.e("971")
3564
3565
  ]).then(__webpack_require__.bind(__webpack_require__, "./src/core/listTests.ts"));
3565
3566
  await listTests(context, options);
@@ -3578,11 +3579,9 @@ ${conflictProjects.map((p)=>`- ${p.configFilePath || p.config.root}`).join('\n')
3578
3579
  WB: ()=>TS_CONFIG_FILE,
3579
3580
  kv: ()=>DEFAULT_CONFIG_EXTENSIONS,
3580
3581
  t: ()=>DEFAULT_CONFIG_NAME,
3581
- vO: ()=>TEST_DELIMITER,
3582
3582
  zZ: ()=>TEMP_RSTEST_OUTPUT_DIR
3583
3583
  });
3584
3584
  const DEFAULT_CONFIG_NAME = 'rstest.config';
3585
- const TEST_DELIMITER = '>';
3586
3585
  const TEMP_RSTEST_OUTPUT_DIR = 'dist/.rstest-temp';
3587
3586
  const TEMP_RSTEST_OUTPUT_DIR_GLOB = '**/dist/.rstest-temp';
3588
3587
  const DEFAULT_CONFIG_EXTENSIONS = [
@@ -4142,15 +4141,15 @@ ${conflictProjects.map((p)=>`- ${p.configFilePath || p.config.root}`).join('\n')
4142
4141
  var pathe__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("../../node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs");
4143
4142
  var picocolors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
4144
4143
  var picocolors__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/ __webpack_require__.n(picocolors__WEBPACK_IMPORTED_MODULE_1__);
4145
- var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/utils/constants.ts");
4146
- const formatRootStr = (rootStr, root)=>rootStr.replace('<rootDir>', root);
4144
+ __webpack_require__("./src/utils/constants.ts");
4145
+ const formatRootStr = (rootStr, root)=>rootStr.replace('<rootDir>', (0, pathe__WEBPACK_IMPORTED_MODULE_2__.n)(root));
4147
4146
  function getAbsolutePath(base, filepath) {
4148
4147
  return (0, pathe__WEBPACK_IMPORTED_MODULE_2__.i)(filepath) ? filepath : (0, pathe__WEBPACK_IMPORTED_MODULE_2__.j)(base, filepath);
4149
4148
  }
4150
4149
  const parsePosix = (filePath)=>{
4151
4150
  const { dir, base } = (0, pathe__WEBPACK_IMPORTED_MODULE_2__.p)(filePath);
4152
4151
  return {
4153
- dir: dir.split(pathe__WEBPACK_IMPORTED_MODULE_2__.s).join('/'),
4152
+ dir: dir.split("/").join('/'),
4154
4153
  base
4155
4154
  };
4156
4155
  };
@@ -4190,7 +4189,7 @@ ${conflictProjects.map((p)=>`- ${p.configFilePath || p.config.root}`).join('\n')
4190
4189
  return time;
4191
4190
  };
4192
4191
  const getTaskNames = (test)=>(test.parentNames || []).concat(test.name).filter(Boolean);
4193
- const getTaskNameWithPrefix = (test, delimiter = _constants__WEBPACK_IMPORTED_MODULE_0__.vO)=>getTaskNames(test).join(` ${delimiter} `);
4192
+ const getTaskNameWithPrefix = (test, delimiter = ">")=>getTaskNames(test).join(` ${delimiter} `);
4194
4193
  const REGEXP_FLAG_PREFIX = 'RSTEST_REGEXP:';
4195
4194
  const wrapRegex = (value)=>`${REGEXP_FLAG_PREFIX}${value.toString()}`;
4196
4195
  const serializableConfig = (normalizedConfig)=>{
@@ -4236,7 +4235,7 @@ ${conflictProjects.map((p)=>`- ${p.configFilePath || p.config.root}`).join('\n')
4236
4235
  fN: ()=>helper.fN,
4237
4236
  vF: ()=>logger.vF,
4238
4237
  Ok: ()=>helper.Ok,
4239
- vO: ()=>constants.vO,
4238
+ vO: ()=>">",
4240
4239
  tG: ()=>getTestEntries,
4241
4240
  FI: ()=>helper.FI,
4242
4241
  Uq: ()=>helper.Uq,
@@ -4446,6 +4445,7 @@ ${conflictProjects.map((p)=>`- ${p.configFilePath || p.config.root}`).join('\n')
4446
4445
  if ('truecolor' === env.COLORTERM) return 3;
4447
4446
  if ('xterm-kitty' === env.TERM) return 3;
4448
4447
  if ('xterm-ghostty' === env.TERM) return 3;
4448
+ if ('wezterm' === env.TERM) return 3;
4449
4449
  if ('TERM_PROGRAM' in env) {
4450
4450
  const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
4451
4451
  switch(env.TERM_PROGRAM){
@@ -4580,6 +4580,14 @@ ${conflictProjects.map((p)=>`- ${p.configFilePath || p.config.root}`).join('\n')
4580
4580
  color: magenta
4581
4581
  }
4582
4582
  };
4583
+ const normalizeErrorMessage = (err)=>{
4584
+ if (err.stack) {
4585
+ let [name, ...rest] = err.stack.split('\n');
4586
+ if (name.startsWith('Error: ')) name = name.slice(7);
4587
+ return `${name}\n${gray(rest.join('\n'))}`;
4588
+ }
4589
+ return err.message;
4590
+ };
4583
4591
  let createLogger = (options = {})=>{
4584
4592
  let maxLevel = options.level || 'info';
4585
4593
  let log = (type, message, ...args)=>{
@@ -4592,12 +4600,14 @@ ${conflictProjects.map((p)=>`- ${p.configFilePath || p.config.root}`).join('\n')
4592
4600
  label = (logType.label || '').padEnd(7);
4593
4601
  label = bold(logType.color ? logType.color(label) : label);
4594
4602
  }
4595
- if (message instanceof Error) if (message.stack) {
4596
- let [name, ...rest] = message.stack.split('\n');
4597
- if (name.startsWith('Error: ')) name = name.slice(7);
4598
- text = `${name}\n${gray(rest.join('\n'))}`;
4599
- } else text = message.message;
4600
- else if ('error' === logType.level && 'string' == typeof message) {
4603
+ if (message instanceof Error) {
4604
+ text += normalizeErrorMessage(message);
4605
+ const { cause } = message;
4606
+ if (cause) {
4607
+ text += yellow('\n [cause]: ');
4608
+ text += cause instanceof Error ? normalizeErrorMessage(cause) : String(cause);
4609
+ }
4610
+ } else if ('error' === logType.level && 'string' == typeof message) {
4601
4611
  let lines = message.split('\n');
4602
4612
  text = lines.map((line)=>isErrorStackMessage(line) ? gray(line) : line).join('\n');
4603
4613
  } else text = `${message}`;
@@ -4709,8 +4719,7 @@ ${conflictProjects.map((p)=>`- ${p.configFilePath || p.config.root}`).join('\n')
4709
4719
  j: ()=>join,
4710
4720
  n: ()=>normalize,
4711
4721
  p: ()=>parse,
4712
- r: ()=>resolve,
4713
- s: ()=>sep
4722
+ r: ()=>resolve
4714
4723
  });
4715
4724
  let _lazyMatch = ()=>{
4716
4725
  var __lib__ = (()=>{
@@ -0,0 +1,125 @@
1
+ const originalWebpackRequire = __webpack_require__;
2
+ __webpack_require__ = new Proxy(function(...args) {
3
+ try {
4
+ return originalWebpackRequire(...args);
5
+ } catch (e) {
6
+ const errMsg = e.message ?? e.toString();
7
+ if (errMsg.includes('__webpack_modules__[moduleId] is not a function')) throw new Error(`[Rstest] Cannot find module "${args[0]}"`);
8
+ throw e;
9
+ }
10
+ }, {
11
+ set (target, property, value) {
12
+ target[property] = value;
13
+ originalWebpackRequire[property] = value;
14
+ return true;
15
+ },
16
+ get (target, property) {
17
+ if (property in target) return target[property];
18
+ return originalWebpackRequire[property];
19
+ }
20
+ });
21
+ __webpack_require__.rstest_original_modules = {};
22
+ __webpack_require__.rstest_original_module_factories = {};
23
+ __webpack_require__.rstest_unmock = (id)=>{
24
+ const originalModuleFactory = __webpack_require__.rstest_original_module_factories[id];
25
+ if (originalModuleFactory) __webpack_modules__[id] = originalModuleFactory;
26
+ delete __webpack_module_cache__[id];
27
+ };
28
+ __webpack_require__.rstest_do_unmock = __webpack_require__.rstest_unmock;
29
+ __webpack_require__.rstest_require_actual = __webpack_require__.rstest_import_actual = (id)=>{
30
+ const originalModule = __webpack_require__.rstest_original_modules[id];
31
+ const fallbackMod = __webpack_require__(id);
32
+ return originalModule ? originalModule : fallbackMod;
33
+ };
34
+ __webpack_require__.rstest_mock = (id, modFactory)=>{
35
+ let requiredModule;
36
+ try {
37
+ requiredModule = __webpack_require__(id);
38
+ } catch {} finally{
39
+ __webpack_require__.rstest_original_modules[id] = requiredModule;
40
+ __webpack_require__.rstest_original_module_factories[id] = __webpack_modules__[id];
41
+ }
42
+ if ('string' == typeof modFactory || 'number' == typeof modFactory) __webpack_module_cache__[id] = {
43
+ exports: __webpack_require__(modFactory)
44
+ };
45
+ else if ('function' == typeof modFactory) {
46
+ const finalModFactory = function(__unused_webpack_module, __webpack_exports__, __webpack_require__1) {
47
+ __webpack_require__1.r(__webpack_exports__);
48
+ const res = modFactory();
49
+ for(const key in res)__webpack_require__1.d(__webpack_exports__, {
50
+ [key]: ()=>res[key]
51
+ });
52
+ };
53
+ __webpack_modules__[id] = finalModFactory;
54
+ delete __webpack_module_cache__[id];
55
+ }
56
+ };
57
+ __webpack_require__.rstest_mock_require = (id, modFactory)=>{
58
+ let requiredModule;
59
+ try {
60
+ requiredModule = __webpack_require__(id);
61
+ } catch {} finally{
62
+ __webpack_require__.rstest_original_modules[id] = requiredModule;
63
+ __webpack_require__.rstest_original_module_factories[id] = __webpack_modules__[id];
64
+ }
65
+ if ('string' == typeof modFactory || 'number' == typeof modFactory) __webpack_module_cache__[id] = {
66
+ exports: __webpack_require__(modFactory)
67
+ };
68
+ else if ('function' == typeof modFactory) {
69
+ const exports = modFactory();
70
+ __webpack_require__.r(exports);
71
+ __webpack_module_cache__[id] = {
72
+ exports,
73
+ id,
74
+ loaded: true
75
+ };
76
+ }
77
+ };
78
+ __webpack_require__.rstest_do_mock = (id, modFactory)=>{
79
+ let requiredModule;
80
+ try {
81
+ requiredModule = __webpack_require__(id);
82
+ } catch {} finally{
83
+ __webpack_require__.rstest_original_modules[id] = requiredModule;
84
+ __webpack_require__.rstest_original_module_factories[id] = __webpack_modules__[id];
85
+ }
86
+ if ('string' == typeof modFactory || 'number' == typeof modFactory) __webpack_module_cache__[id] = {
87
+ exports: __webpack_require__(modFactory)
88
+ };
89
+ else if ('function' == typeof modFactory) {
90
+ const exports = modFactory();
91
+ __webpack_require__.r(exports);
92
+ __webpack_module_cache__[id] = {
93
+ exports,
94
+ id,
95
+ loaded: true
96
+ };
97
+ }
98
+ };
99
+ __webpack_require__.rstest_do_mock_require = (id, modFactory)=>{
100
+ let requiredModule;
101
+ try {
102
+ requiredModule = __webpack_require__(id);
103
+ } catch {} finally{
104
+ __webpack_require__.rstest_original_modules[id] = requiredModule;
105
+ __webpack_require__.rstest_original_module_factories[id] = __webpack_modules__[id];
106
+ }
107
+ if ('string' == typeof modFactory || 'number' == typeof modFactory) __webpack_module_cache__[id] = {
108
+ exports: __webpack_require__(modFactory)
109
+ };
110
+ else if ('function' == typeof modFactory) {
111
+ const exports = modFactory();
112
+ __webpack_require__.r(exports);
113
+ __webpack_module_cache__[id] = {
114
+ exports,
115
+ id,
116
+ loaded: true
117
+ };
118
+ }
119
+ };
120
+ __webpack_require__.rstest_reset_modules = ()=>{
121
+ const mockedIds = Object.keys(__webpack_require__.rstest_original_modules);
122
+ Object.keys(__webpack_module_cache__).forEach((id)=>{
123
+ if (!mockedIds.includes(id)) delete __webpack_module_cache__[id];
124
+ });
125
+ };
package/dist/worker.js CHANGED
@@ -2905,7 +2905,7 @@ var __webpack_modules__ = {
2905
2905
  return -1 !== position && (-1 === terminatorPosition || position < terminatorPosition);
2906
2906
  };
2907
2907
  },
2908
- "../../node_modules/.pnpm/jest-diff@30.1.2/node_modules/jest-diff/build/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
2908
+ "../../node_modules/.pnpm/jest-diff@30.2.0/node_modules/jest-diff/build/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
2909
2909
  /*!
2910
2910
  * /**
2911
2911
  * * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -3770,7 +3770,7 @@ var __webpack_modules__ = {
3770
3770
  });
3771
3771
  var _chalk = _interopRequireDefault(__webpack_require__("../../node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/index.js"));
3772
3772
  var _getType = __webpack_require__("../../node_modules/.pnpm/@jest+get-type@30.1.0/node_modules/@jest/get-type/build/index.js");
3773
- var _prettyFormat = __webpack_require__("../../node_modules/.pnpm/pretty-format@30.0.5/node_modules/pretty-format/build/index.js");
3773
+ var _prettyFormat = __webpack_require__("../../node_modules/.pnpm/pretty-format@30.2.0/node_modules/pretty-format/build/index.js");
3774
3774
  var _cleanupSemantic = __nested_webpack_require_48295__("./src/cleanupSemantic.ts");
3775
3775
  var _constants = __nested_webpack_require_48295__("./src/constants.ts");
3776
3776
  var _diffLines = __nested_webpack_require_48295__("./src/diffLines.ts");
@@ -3954,7 +3954,7 @@ var __webpack_modules__ = {
3954
3954
  module.exports = createColors();
3955
3955
  module.exports.createColors = createColors;
3956
3956
  },
3957
- "../../node_modules/.pnpm/pretty-format@30.0.5/node_modules/pretty-format/build/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
3957
+ "../../node_modules/.pnpm/pretty-format@30.2.0/node_modules/pretty-format/build/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
3958
3958
  /*!
3959
3959
  * /**
3960
3960
  * * Copyright (c) Meta Platforms, Inc. and affiliates.
@@ -4494,6 +4494,7 @@ var __webpack_modules__ = {
4494
4494
  if ('function' === typeOf) return printFunction(val, printFunctionName);
4495
4495
  if ('symbol' === typeOf) return printSymbol(val);
4496
4496
  const toStringed = src_toString.call(val);
4497
+ if ('[object Promise]' === toStringed) return 'Promise {}';
4497
4498
  if ('[object WeakMap]' === toStringed) return 'WeakMap {}';
4498
4499
  if ('[object WeakSet]' === toStringed) return 'WeakSet {}';
4499
4500
  if ('[object Function]' === toStringed || '[object GeneratorFunction]' === toStringed) return printFunction(val, printFunctionName);
@@ -6417,7 +6418,6 @@ var __webpack_modules__ = {
6417
6418
  map: map
6418
6419
  };
6419
6420
  };
6420
- exports.SourceNode = SourceNode;
6421
6421
  },
6422
6422
  "../../node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/util.js": function(__unused_webpack_module, exports) {
6423
6423
  function getArg(aArgs, aName, aDefaultValue) {
@@ -6621,7 +6621,7 @@ var __webpack_modules__ = {
6621
6621
  "../../node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/source-map.js": function(__unused_webpack_module, exports, __webpack_require__) {
6622
6622
  __webpack_require__("../../node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/source-map-generator.js").SourceMapGenerator;
6623
6623
  exports.SourceMapConsumer = __webpack_require__("../../node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/source-map-consumer.js").SourceMapConsumer;
6624
- __webpack_require__("../../node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/source-node.js").SourceNode;
6624
+ __webpack_require__("../../node_modules/.pnpm/source-map@0.6.1/node_modules/source-map/lib/source-node.js");
6625
6625
  },
6626
6626
  "../../node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js": function(module, __unused_webpack_exports, __webpack_require__) {
6627
6627
  const os = __webpack_require__("node:os");
@@ -6701,7 +6701,7 @@ var __webpack_modules__ = {
6701
6701
  });
6702
6702
  var external_node_module_ = __webpack_require__("node:module");
6703
6703
  var external_node_util_ = __webpack_require__("node:util");
6704
- var build = __webpack_require__("../../node_modules/.pnpm/jest-diff@30.1.2/node_modules/jest-diff/build/index.js");
6704
+ var build = __webpack_require__("../../node_modules/.pnpm/jest-diff@30.2.0/node_modules/jest-diff/build/index.js");
6705
6705
  build.DIFF_DELETE;
6706
6706
  build.DIFF_EQUAL;
6707
6707
  build.DIFF_INSERT;
@@ -6714,7 +6714,7 @@ var __webpack_modules__ = {
6714
6714
  build.diffStringsUnified;
6715
6715
  const REAL_TIMERS = {};
6716
6716
  const setRealTimers = ()=>{
6717
- REAL_TIMERS.setTimeout ??= globalThis.setTimeout;
6717
+ REAL_TIMERS.setTimeout ??= globalThis.setTimeout.bind(globalThis);
6718
6718
  };
6719
6719
  const getRealTimers = ()=>REAL_TIMERS;
6720
6720
  const formatTestError = (err, test)=>{
@@ -6794,10 +6794,8 @@ var __webpack_modules__ = {
6794
6794
  "./src/utils/constants.ts": function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
6795
6795
  __webpack_require__.d(__webpack_exports__, {
6796
6796
  TE: ()=>globalApis,
6797
- q_: ()=>ROOT_SUITE_NAME,
6798
- vO: ()=>TEST_DELIMITER
6797
+ q_: ()=>ROOT_SUITE_NAME
6799
6798
  });
6800
- const TEST_DELIMITER = '>';
6801
6799
  const ROOT_SUITE_NAME = 'Rstest:_internal_root_suite';
6802
6800
  const globalApis = [
6803
6801
  'test',
@@ -6826,7 +6824,7 @@ var __webpack_modules__ = {
6826
6824
  });
6827
6825
  var picocolors__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
6828
6826
  var picocolors__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/ __webpack_require__.n(picocolors__WEBPACK_IMPORTED_MODULE_1__);
6829
- var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./src/utils/constants.ts");
6827
+ __webpack_require__("./src/utils/constants.ts");
6830
6828
  const isObject = (obj)=>'[object Object]' === Object.prototype.toString.call(obj);
6831
6829
  const castArray = (arr)=>{
6832
6830
  if (void 0 === arr) return [];
@@ -6853,7 +6851,7 @@ var __webpack_modules__ = {
6853
6851
  return time;
6854
6852
  };
6855
6853
  const getTaskNames = (test)=>(test.parentNames || []).concat(test.name).filter(Boolean);
6856
- const getTaskNameWithPrefix = (test, delimiter = _constants__WEBPACK_IMPORTED_MODULE_0__.vO)=>getTaskNames(test).join(` ${delimiter} `);
6854
+ const getTaskNameWithPrefix = (test, delimiter = ">")=>getTaskNames(test).join(` ${delimiter} `);
6857
6855
  const REGEXP_FLAG_PREFIX = 'RSTEST_REGEXP:';
6858
6856
  const unwrapRegex = (value)=>{
6859
6857
  if (value.startsWith(REGEXP_FLAG_PREFIX)) {
@@ -6967,6 +6965,7 @@ var __webpack_modules__ = {
6967
6965
  if ('truecolor' === env.COLORTERM) return 3;
6968
6966
  if ('xterm-kitty' === env.TERM) return 3;
6969
6967
  if ('xterm-ghostty' === env.TERM) return 3;
6968
+ if ('wezterm' === env.TERM) return 3;
6970
6969
  if ('TERM_PROGRAM' in env) {
6971
6970
  const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
6972
6971
  switch(env.TERM_PROGRAM){
@@ -7101,6 +7100,14 @@ var __webpack_modules__ = {
7101
7100
  color: magenta
7102
7101
  }
7103
7102
  };
7103
+ const normalizeErrorMessage = (err)=>{
7104
+ if (err.stack) {
7105
+ let [name, ...rest] = err.stack.split('\n');
7106
+ if (name.startsWith('Error: ')) name = name.slice(7);
7107
+ return `${name}\n${gray(rest.join('\n'))}`;
7108
+ }
7109
+ return err.message;
7110
+ };
7104
7111
  let createLogger = (options = {})=>{
7105
7112
  let maxLevel = options.level || 'info';
7106
7113
  let log = (type, message, ...args)=>{
@@ -7113,12 +7120,14 @@ var __webpack_modules__ = {
7113
7120
  label = (logType.label || '').padEnd(7);
7114
7121
  label = bold(logType.color ? logType.color(label) : label);
7115
7122
  }
7116
- if (message instanceof Error) if (message.stack) {
7117
- let [name, ...rest] = message.stack.split('\n');
7118
- if (name.startsWith('Error: ')) name = name.slice(7);
7119
- text = `${name}\n${gray(rest.join('\n'))}`;
7120
- } else text = message.message;
7121
- else if ('error' === logType.level && 'string' == typeof message) {
7123
+ if (message instanceof Error) {
7124
+ text += normalizeErrorMessage(message);
7125
+ const { cause } = message;
7126
+ if (cause) {
7127
+ text += yellow('\n [cause]: ');
7128
+ text += cause instanceof Error ? normalizeErrorMessage(cause) : String(cause);
7129
+ }
7130
+ } else if ('error' === logType.level && 'string' == typeof message) {
7122
7131
  let lines = message.split('\n');
7123
7132
  text = lines.map((line)=>isErrorStackMessage(line) ? gray(line) : line).join('\n');
7124
7133
  } else text = `${message}`;
@@ -8081,7 +8090,7 @@ function createBirpc(functions, options) {
8081
8090
  if (msg.t === TYPE_REQUEST) {
8082
8091
  const { m: method, a: args } = msg;
8083
8092
  let result, error;
8084
- const fn = resolver ? resolver(method, functions[method]) : functions[method];
8093
+ const fn = await (resolver ? resolver(method, functions[method]) : functions[method]);
8085
8094
  if (fn) try {
8086
8095
  result = await fn.apply("rpc" === bind ? rpc : functions, args);
8087
8096
  } catch (e) {
@@ -8233,6 +8242,7 @@ const setupEnv = (env)=>{
8233
8242
  const preparePool = async ({ entryInfo: { distPath, testPath }, updateSnapshot, context })=>{
8234
8243
  (0, util.zH)();
8235
8244
  context.runtimeConfig = (0, helper.gy)(context.runtimeConfig);
8245
+ process.env.RSTEST_WORKER_ID = String(process.__tinypool_state__.workerId || context.taskId);
8236
8246
  const cleanupFns = [];
8237
8247
  const { rpc } = createRuntimeRpc(createForksRpcOptions());
8238
8248
  const { runtimeConfig: { globals, printConsoleTrace, disableConsoleIntercept, testEnvironment, snapshotFormat, env } } = context;
@@ -2746,6 +2746,7 @@ declare type TestContext = {
2746
2746
  declare interface TestEachFn {
2747
2747
  <T extends Record<string, unknown>>(cases: readonly T[]): (description: string, fn?: (param: T) => MaybePromise<void>, timeout?: number) => void;
2748
2748
  <T extends readonly [unknown, ...unknown[]]>(cases: readonly T[]): (description: string, fn: (...args: [...T]) => MaybePromise<void>, timeout?: number) => void;
2749
+ <T>(cases: readonly T[]): (description: string, fn: (...args: T[]) => MaybePromise<void>, timeout?: number) => void;
2749
2750
  }
2750
2751
 
2751
2752
  declare type Tester = (this: TesterContext, a: any, b: any, customTesters: Array<Tester>) => boolean | undefined;
@@ -2342,6 +2342,7 @@ declare type TestContext = {
2342
2342
  declare interface TestEachFn {
2343
2343
  <T extends Record<string, unknown>>(cases: readonly T[]): (description: string, fn?: (param: T) => MaybePromise<void>, timeout?: number) => void;
2344
2344
  <T extends readonly [unknown, ...unknown[]]>(cases: readonly T[]): (description: string, fn: (...args: [...T]) => MaybePromise<void>, timeout?: number) => void;
2345
+ <T>(cases: readonly T[]): (description: string, fn: (...args: T[]) => MaybePromise<void>, timeout?: number) => void;
2345
2346
  }
2346
2347
 
2347
2348
  declare type Tester = (this: TesterContext, a: any, b: any, customTesters: Array<Tester>) => boolean | undefined;
@@ -2481,6 +2482,7 @@ declare type WorkerContext = {
2481
2482
  projectRoot: ProjectContext['rootPath'];
2482
2483
  project: string;
2483
2484
  runtimeConfig: RuntimeConfig;
2485
+ taskId: number;
2484
2486
  };
2485
2487
 
2486
2488
  declare type XInput = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rstest/core",
3
- "version": "0.5.4",
3
+ "version": "0.6.1",
4
4
  "description": "The Rsbuild-based test tool.",
5
5
  "bugs": {
6
6
  "url": "https://github.com/web-infra-dev/rstest/issues"
@@ -47,20 +47,20 @@
47
47
  "importMeta.d.ts"
48
48
  ],
49
49
  "dependencies": {
50
- "@types/chai": "^5.2.2",
51
- "@rsbuild/core": "1.5.0",
50
+ "@types/chai": "^5.2.3",
51
+ "@rsbuild/core": "1.6.0-beta.1",
52
52
  "tinypool": "^1.1.1"
53
53
  },
54
54
  "devDependencies": {
55
55
  "chai": "^5.3.3",
56
56
  "pathe": "^2.0.3",
57
- "birpc": "2.5.0",
57
+ "birpc": "2.6.1",
58
58
  "@vitest/expect": "^3.2.4",
59
59
  "@vitest/snapshot": "^3.2.4",
60
60
  "@babel/code-frame": "^7.27.1",
61
61
  "@jridgewell/trace-mapping": "0.3.31",
62
- "@microsoft/api-extractor": "^7.52.13",
63
- "@rslib/core": "0.13.3",
62
+ "@microsoft/api-extractor": "^7.53.3",
63
+ "@rslib/core": "0.16.1",
64
64
  "@sinonjs/fake-timers": "^14.0.0",
65
65
  "@types/babel__code-frame": "^7.0.6",
66
66
  "@types/istanbul-reports": "^3.0.4",
@@ -71,18 +71,18 @@
71
71
  "@types/picomatch": "^4.0.2",
72
72
  "cac": "^6.7.14",
73
73
  "chokidar": "^4.0.3",
74
- "happy-dom": "^20.0.0",
75
- "jest-diff": "^30.1.2",
74
+ "happy-dom": "^20.0.8",
75
+ "jest-diff": "^30.2.0",
76
76
  "jsdom": "^26.1.0",
77
77
  "webpack-license-plugin": "^4.5.1",
78
78
  "picocolors": "^1.1.1",
79
- "rslog": "^1.2.11",
79
+ "rslog": "^1.3.0",
80
80
  "source-map-support": "^0.5.21",
81
- "std-env": "^3.9.0",
81
+ "std-env": "^3.10.0",
82
82
  "stacktrace-parser": "0.1.11",
83
83
  "strip-ansi": "^7.1.2",
84
84
  "tinyglobby": "^0.2.15",
85
- "tinyspy": "^4.0.3",
85
+ "tinyspy": "^4.0.4",
86
86
  "picomatch": "^4.0.3",
87
87
  "@rstest/tsconfig": "0.0.1"
88
88
  },