@rstest/core 0.7.2 → 0.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/0~130.js CHANGED
@@ -3,7 +3,8 @@ import 'module';
3
3
  import { __webpack_require__ } from "./rslib-runtime.js";
4
4
  import { AssertionError, strict } from "node:assert";
5
5
  import { Console } from "node:console";
6
- import { prettyTime } from "./946.js";
6
+ import "./664.js";
7
+ import { prettyTime } from "./157.js";
7
8
  const external_node_util_ = __webpack_require__("node:util");
8
9
  const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
9
10
  var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
package/dist/0~151.js CHANGED
@@ -2,10 +2,15 @@
2
2
  import 'module';
3
3
  /*#__PURE__*/ import.meta.url;
4
4
  import { __webpack_require__ } from "./rslib-runtime.js";
5
- import { getTaskNameWithPrefix, isObject as helper_isObject, castArray, resolve as pathe_M_eThtNZ_resolve, ROOT_SUITE_NAME } from "./946.js";
6
- import { getRealTimers, TestRegisterError, formatTestError, formatName } from "./554.js";
5
+ import "./664.js";
6
+ import { resolve as pathe_M_eThtNZ_resolve } from "./278.js";
7
+ import { getTaskNameWithPrefix, isObject as helper_isObject, castArray, ROOT_SUITE_NAME } from "./157.js";
8
+ import { getRealTimers, TestRegisterError, formatTestError, formatName } from "./913.js";
9
+ import { fileURLToPath } from "./198.js";
10
+ import { parse } from "./672.js";
11
+ import "./554.js";
7
12
  __webpack_require__.add({
8
- "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/called-in-order.js" (module, __unused_webpack_exports, __webpack_require__) {
13
+ "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/called-in-order.js" (module, __unused_rspack_exports, __webpack_require__) {
9
14
  var every = __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/array.js").every;
10
15
  function hasCallsLeft(callMap, spy) {
11
16
  if (void 0 === callMap[spy.id]) callMap[spy.id] = 0;
@@ -34,7 +39,7 @@ __webpack_require__.add({
34
39
  }
35
40
  module.exports = className;
36
41
  },
37
- "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/deprecated.js" (__unused_webpack_module, exports) {
42
+ "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/deprecated.js" (__unused_rspack_module, exports) {
38
43
  exports.wrap = function(func, msg) {
39
44
  var wrapped = function() {
40
45
  exports.printWarning(msg);
@@ -80,7 +85,7 @@ __webpack_require__.add({
80
85
  globalObject = "undefined" != typeof global ? global : "undefined" != typeof window ? window : self;
81
86
  module.exports = globalObject;
82
87
  },
83
- "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/index.js" (module, __unused_webpack_exports, __webpack_require__) {
88
+ "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/index.js" (module, __unused_rspack_exports, __webpack_require__) {
84
89
  module.exports = {
85
90
  global: __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/global.js"),
86
91
  calledInOrder: __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/called-in-order.js"),
@@ -94,7 +99,7 @@ __webpack_require__.add({
94
99
  valueToString: __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/value-to-string.js")
95
100
  };
96
101
  },
97
- "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/order-by-first-call.js" (module, __unused_webpack_exports, __webpack_require__) {
102
+ "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/order-by-first-call.js" (module, __unused_rspack_exports, __webpack_require__) {
98
103
  var sort = __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/array.js").sort;
99
104
  var slice = __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/array.js").slice;
100
105
  function comparator(a, b) {
@@ -109,11 +114,11 @@ __webpack_require__.add({
109
114
  }
110
115
  module.exports = orderByFirstCall;
111
116
  },
112
- "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/array.js" (module, __unused_webpack_exports, __webpack_require__) {
117
+ "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/array.js" (module, __unused_rspack_exports, __webpack_require__) {
113
118
  var copyPrototype = __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/copy-prototype-methods.js");
114
119
  module.exports = copyPrototype(Array.prototype);
115
120
  },
116
- "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/copy-prototype-methods.js" (module, __unused_webpack_exports, __webpack_require__) {
121
+ "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/copy-prototype-methods.js" (module, __unused_rspack_exports, __webpack_require__) {
117
122
  var call = Function.call;
118
123
  var throwsOnProto = __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/throws-on-proto.js");
119
124
  var disallowedProperties = [
@@ -132,11 +137,11 @@ __webpack_require__.add({
132
137
  }, Object.create(null));
133
138
  };
134
139
  },
135
- "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/function.js" (module, __unused_webpack_exports, __webpack_require__) {
140
+ "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/function.js" (module, __unused_rspack_exports, __webpack_require__) {
136
141
  var copyPrototype = __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/copy-prototype-methods.js");
137
142
  module.exports = copyPrototype(Function.prototype);
138
143
  },
139
- "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/index.js" (module, __unused_webpack_exports, __webpack_require__) {
144
+ "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/index.js" (module, __unused_rspack_exports, __webpack_require__) {
140
145
  module.exports = {
141
146
  array: __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/array.js"),
142
147
  function: __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/function.js"),
@@ -146,19 +151,19 @@ __webpack_require__.add({
146
151
  string: __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/string.js")
147
152
  };
148
153
  },
149
- "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/map.js" (module, __unused_webpack_exports, __webpack_require__) {
154
+ "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/map.js" (module, __unused_rspack_exports, __webpack_require__) {
150
155
  var copyPrototype = __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/copy-prototype-methods.js");
151
156
  module.exports = copyPrototype(Map.prototype);
152
157
  },
153
- "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/object.js" (module, __unused_webpack_exports, __webpack_require__) {
158
+ "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/object.js" (module, __unused_rspack_exports, __webpack_require__) {
154
159
  var copyPrototype = __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/copy-prototype-methods.js");
155
160
  module.exports = copyPrototype(Object.prototype);
156
161
  },
157
- "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/set.js" (module, __unused_webpack_exports, __webpack_require__) {
162
+ "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/set.js" (module, __unused_rspack_exports, __webpack_require__) {
158
163
  var copyPrototype = __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/copy-prototype-methods.js");
159
164
  module.exports = copyPrototype(Set.prototype);
160
165
  },
161
- "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/string.js" (module, __unused_webpack_exports, __webpack_require__) {
166
+ "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/string.js" (module, __unused_rspack_exports, __webpack_require__) {
162
167
  var copyPrototype = __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/copy-prototype-methods.js");
163
168
  module.exports = copyPrototype(String.prototype);
164
169
  },
@@ -173,7 +178,7 @@ __webpack_require__.add({
173
178
  }
174
179
  module.exports = throwsOnProto;
175
180
  },
176
- "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/type-of.js" (module, __unused_webpack_exports, __webpack_require__) {
181
+ "../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/type-of.js" (module, __unused_rspack_exports, __webpack_require__) {
177
182
  var type = __webpack_require__("../../node_modules/.pnpm/type-detect@4.0.8/node_modules/type-detect/type-detect.js");
178
183
  module.exports = function typeOf(value) {
179
184
  return type(value).toLowerCase();
@@ -186,7 +191,7 @@ __webpack_require__.add({
186
191
  }
187
192
  module.exports = valueToString;
188
193
  },
189
- "../../node_modules/.pnpm/@sinonjs+fake-timers@14.0.0/node_modules/@sinonjs/fake-timers/src/fake-timers-src.js" (__unused_webpack_module, exports, __webpack_require__) {
194
+ "../../node_modules/.pnpm/@sinonjs+fake-timers@15.0.0/node_modules/@sinonjs/fake-timers/src/fake-timers-src.js" (__unused_rspack_module, exports, __webpack_require__) {
190
195
  const globalObject = __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/index.js").global;
191
196
  let timersModule, timersPromisesModule;
192
197
  try {
@@ -532,7 +537,7 @@ __webpack_require__.add({
532
537
  }
533
538
  }
534
539
  }
535
- function uninstall(clock, config) {
540
+ function uninstall(clock) {
536
541
  let method, i, l;
537
542
  const installedHrTime = "_hrtime";
538
543
  const installedNextTick = "_nextTick";
@@ -557,7 +562,7 @@ __webpack_require__.add({
557
562
  timersPromisesModule[entry.methodName] = entry.original;
558
563
  }
559
564
  }
560
- if (true === config.shouldAdvanceTime) _global.clearInterval(clock.attachedInterval);
565
+ clock.setTickMode("manual");
561
566
  clock.methods = [];
562
567
  for (const [listener, signal] of clock.abortListenerMap.entries()){
563
568
  signal.removeEventListener("abort", listener);
@@ -610,6 +615,8 @@ __webpack_require__.add({
610
615
  if (isPresent.cancelIdleCallback) timers.cancelIdleCallback = _global.cancelIdleCallback;
611
616
  if (isPresent.Intl) timers.Intl = NativeIntl;
612
617
  const originalSetTimeout = _global.setImmediate || _global.setTimeout;
618
+ const originalClearInterval = _global.clearInterval;
619
+ const originalSetInterval = _global.setInterval;
613
620
  function createClock(start, loopLimit) {
614
621
  start = Math.floor(getEpoch(start));
615
622
  loopLimit = loopLimit || 1000;
@@ -621,7 +628,12 @@ __webpack_require__.add({
621
628
  const clock = {
622
629
  now: start,
623
630
  Date: createDate(),
624
- loopLimit: loopLimit
631
+ loopLimit: loopLimit,
632
+ tickMode: {
633
+ mode: "manual",
634
+ counter: 0,
635
+ delta: void 0
636
+ }
625
637
  };
626
638
  clock.Date.clock = clock;
627
639
  function getTimeToNextFrame() {
@@ -663,6 +675,53 @@ __webpack_require__.add({
663
675
  clock.Intl = createIntl();
664
676
  clock.Intl.clock = clock;
665
677
  }
678
+ clock.setTickMode = function(tickModeConfig) {
679
+ const { mode: newMode, delta: newDelta } = tickModeConfig;
680
+ const { mode: oldMode, delta: oldDelta } = clock.tickMode;
681
+ if (newMode === oldMode && newDelta === oldDelta) return;
682
+ if ("interval" === oldMode) originalClearInterval(clock.attachedInterval);
683
+ clock.tickMode = {
684
+ counter: clock.tickMode.counter + 1,
685
+ mode: newMode,
686
+ delta: newDelta
687
+ };
688
+ if ("nextAsync" === newMode) advanceUntilModeChanges();
689
+ else if ("interval" === newMode) createIntervalTick(clock, newDelta || 20);
690
+ };
691
+ async function advanceUntilModeChanges() {
692
+ async function newMacrotask() {
693
+ const channel = new MessageChannel();
694
+ await new Promise((resolve)=>{
695
+ channel.port1.onmessage = ()=>{
696
+ resolve();
697
+ channel.port1.close();
698
+ };
699
+ channel.port2.postMessage(void 0);
700
+ });
701
+ channel.port1.close();
702
+ channel.port2.close();
703
+ await new Promise((resolve)=>{
704
+ originalSetTimeout(resolve);
705
+ });
706
+ }
707
+ const { counter } = clock.tickMode;
708
+ while(clock.tickMode.counter === counter){
709
+ await newMacrotask();
710
+ if (clock.tickMode.counter !== counter) return;
711
+ clock.next();
712
+ }
713
+ }
714
+ function pauseAutoTickUntilFinished(promise) {
715
+ if ("nextAsync" !== clock.tickMode.mode) return promise;
716
+ clock.setTickMode({
717
+ mode: "manual"
718
+ });
719
+ return promise.finally(()=>{
720
+ clock.setTickMode({
721
+ mode: "nextAsync"
722
+ });
723
+ });
724
+ }
666
725
  clock.requestIdleCallback = function requestIdleCallback(func, timeout) {
667
726
  let timeToNextIdlePeriod = 0;
668
727
  if (clock.countTimers() > 0) timeToNextIdlePeriod = 50;
@@ -852,7 +911,7 @@ __webpack_require__.add({
852
911
  return doTick(tickValue, false);
853
912
  };
854
913
  if (void 0 !== _global.Promise) clock.tickAsync = function tickAsync(tickValue) {
855
- return new _global.Promise(function(resolve, reject) {
914
+ return pauseAutoTickUntilFinished(new _global.Promise(function(resolve, reject) {
856
915
  originalSetTimeout(function() {
857
916
  try {
858
917
  doTick(tickValue, true, resolve, reject);
@@ -860,7 +919,7 @@ __webpack_require__.add({
860
919
  reject(e);
861
920
  }
862
921
  });
863
- });
922
+ }));
864
923
  };
865
924
  clock.next = function next() {
866
925
  runJobs(clock);
@@ -877,7 +936,7 @@ __webpack_require__.add({
877
936
  }
878
937
  };
879
938
  if (void 0 !== _global.Promise) clock.nextAsync = function nextAsync() {
880
- return new _global.Promise(function(resolve, reject) {
939
+ return pauseAutoTickUntilFinished(new _global.Promise(function(resolve, reject) {
881
940
  originalSetTimeout(function() {
882
941
  try {
883
942
  const timer = firstTimer(clock);
@@ -899,7 +958,7 @@ __webpack_require__.add({
899
958
  reject(e);
900
959
  }
901
960
  });
902
- });
961
+ }));
903
962
  };
904
963
  clock.runAll = function runAll() {
905
964
  let numTimers, i;
@@ -924,7 +983,7 @@ __webpack_require__.add({
924
983
  return clock.tick(getTimeToNextFrame());
925
984
  };
926
985
  if (void 0 !== _global.Promise) clock.runAllAsync = function runAllAsync() {
927
- return new _global.Promise(function(resolve, reject) {
986
+ return pauseAutoTickUntilFinished(new _global.Promise(function(resolve, reject) {
928
987
  let i = 0;
929
988
  function doRun() {
930
989
  originalSetTimeout(function() {
@@ -957,7 +1016,7 @@ __webpack_require__.add({
957
1016
  });
958
1017
  }
959
1018
  doRun();
960
- });
1019
+ }));
961
1020
  };
962
1021
  clock.runToLast = function runToLast() {
963
1022
  const timer = lastTimer(clock);
@@ -968,7 +1027,7 @@ __webpack_require__.add({
968
1027
  return clock.tick(timer.callAt - clock.now);
969
1028
  };
970
1029
  if (void 0 !== _global.Promise) clock.runToLastAsync = function runToLastAsync() {
971
- return new _global.Promise(function(resolve, reject) {
1030
+ return pauseAutoTickUntilFinished(new _global.Promise(function(resolve, reject) {
972
1031
  originalSetTimeout(function() {
973
1032
  try {
974
1033
  const timer = lastTimer(clock);
@@ -981,7 +1040,7 @@ __webpack_require__.add({
981
1040
  reject(e);
982
1041
  }
983
1042
  });
984
- });
1043
+ }));
985
1044
  };
986
1045
  clock.reset = function reset() {
987
1046
  nanos = 0;
@@ -1016,6 +1075,11 @@ __webpack_require__.add({
1016
1075
  if (isPresent.hrtime) clock.hrtime = hrtime;
1017
1076
  return clock;
1018
1077
  }
1078
+ function createIntervalTick(clock, delta) {
1079
+ const intervalTick = doIntervalTick.bind(null, clock, delta);
1080
+ const intervalId = originalSetInterval(intervalTick, delta);
1081
+ clock.attachedInterval = intervalId;
1082
+ }
1019
1083
  function install(config) {
1020
1084
  if (arguments.length > 1 || config instanceof Date || Array.isArray(config) || "number" == typeof config) throw new TypeError(`FakeTimers.install called with ${String(config)} install requires an object parameter`);
1021
1085
  if (true === _global.Date.isFake) throw new TypeError("Can't install fake timers twice on the same global object.");
@@ -1032,16 +1096,15 @@ __webpack_require__.add({
1032
1096
  const clock = createClock(config.now, config.loopLimit);
1033
1097
  clock.shouldClearNativeTimers = config.shouldClearNativeTimers;
1034
1098
  clock.uninstall = function() {
1035
- return uninstall(clock, config);
1099
+ return uninstall(clock);
1036
1100
  };
1037
1101
  clock.abortListenerMap = new Map();
1038
1102
  clock.methods = config.toFake || [];
1039
1103
  if (0 === clock.methods.length) clock.methods = Object.keys(timers);
1040
- if (true === config.shouldAdvanceTime) {
1041
- const intervalTick = doIntervalTick.bind(null, clock, config.advanceTimeDelta);
1042
- const intervalId = _global.setInterval(intervalTick, config.advanceTimeDelta);
1043
- clock.attachedInterval = intervalId;
1044
- }
1104
+ if (true === config.shouldAdvanceTime) clock.setTickMode({
1105
+ mode: "interval",
1106
+ delta: config.advanceTimeDelta
1107
+ });
1045
1108
  if (clock.methods.includes("performance")) {
1046
1109
  const proto = (()=>{
1047
1110
  if (hasPerformanceConstructorPrototype) return _global.performance.constructor.prototype;
@@ -12055,12 +12118,17 @@ function makeError(message, stackTraceError) {
12055
12118
  if (stackTraceError?.stack) error.stack = stackTraceError.stack.replace(error.message, stackTraceError.message);
12056
12119
  return error;
12057
12120
  }
12058
- function wrapTimeout({ name, fn, timeout, stackTraceError }) {
12121
+ function wrapTimeout({ name, fn, timeout, getAssertionCalls, stackTraceError }) {
12059
12122
  if (!timeout) return fn;
12060
12123
  return async (...args)=>{
12061
12124
  let timeoutId;
12062
12125
  const timeoutPromise = new Promise((_, reject)=>{
12063
- timeoutId = getRealTimers().setTimeout(()=>reject(makeError(`${name} timed out in ${timeout}ms`, stackTraceError)), timeout);
12126
+ timeoutId = getRealTimers().setTimeout(()=>{
12127
+ const assertionCalls = getAssertionCalls?.() || 0;
12128
+ const assertionInfo = assertionCalls > 0 ? ` (completed ${assertionCalls} expect assertion${1 === assertionCalls ? '' : 's'})` : ' (no expect assertions completed)';
12129
+ const message = `${name} timed out in ${timeout}ms${getAssertionCalls ? assertionInfo : ''}`;
12130
+ reject(makeError(message, stackTraceError));
12131
+ }, timeout);
12064
12132
  });
12065
12133
  try {
12066
12134
  const result = await Promise.race([
@@ -12135,9 +12203,11 @@ class TestRunner {
12135
12203
  let result;
12136
12204
  this.beforeEach(test, state, api);
12137
12205
  const cleanups = [];
12206
+ const fixtureCleanups = await this.beforeRunTest(test, snapshotClient.getSnapshotState(testPath));
12207
+ cleanups.push(...fixtureCleanups);
12138
12208
  try {
12139
12209
  for (const fn of parentHooks.beforeEachListeners){
12140
- const cleanupFn = await fn();
12210
+ const cleanupFn = await fn(test.context);
12141
12211
  cleanupFn && cleanups.push(cleanupFn);
12142
12212
  }
12143
12213
  } catch (error) {
@@ -12152,8 +12222,6 @@ class TestRunner {
12152
12222
  };
12153
12223
  }
12154
12224
  if (result?.status !== 'fail') if (test.fails) try {
12155
- const fixtureCleanups = await this.beforeRunTest(test, snapshotClient.getSnapshotState(testPath));
12156
- cleanups.push(...fixtureCleanups);
12157
12225
  await test.fn?.(test.context);
12158
12226
  this.afterRunTest(test);
12159
12227
  result = {
@@ -12180,9 +12248,20 @@ class TestRunner {
12180
12248
  };
12181
12249
  }
12182
12250
  else try {
12183
- const fixtureCleanups = await this.beforeRunTest(test, snapshotClient.getSnapshotState(testPath));
12184
- cleanups.push(...fixtureCleanups);
12185
- await test.fn?.(test.context);
12251
+ if (test.fn) {
12252
+ const fn = wrapTimeout({
12253
+ name: 'test',
12254
+ fn: test.fn,
12255
+ timeout: test.timeout,
12256
+ stackTraceError: test.stackTraceError,
12257
+ getAssertionCalls: ()=>{
12258
+ const expect = test.context._useLocalExpect ? test.context.expect : globalThis[GLOBAL_EXPECT];
12259
+ const { assertionCalls } = getState(expect);
12260
+ return assertionCalls;
12261
+ }
12262
+ });
12263
+ await fn(test.context);
12264
+ }
12186
12265
  this.afterRunTest(test);
12187
12266
  result = {
12188
12267
  testId: test.testId,
@@ -12206,12 +12285,9 @@ class TestRunner {
12206
12285
  const afterEachFns = [
12207
12286
  ...parentHooks.afterEachListeners || []
12208
12287
  ].reverse().concat(cleanups).concat(test.onFinished);
12288
+ test.context.task.result = result;
12209
12289
  try {
12210
- for (const fn of afterEachFns)await fn({
12211
- task: {
12212
- result
12213
- }
12214
- });
12290
+ for (const fn of afterEachFns)await fn(test.context);
12215
12291
  } catch (error) {
12216
12292
  result.status = 'fail';
12217
12293
  result.errors ??= [];
@@ -12220,11 +12296,7 @@ class TestRunner {
12220
12296
  if ('fail' === result.status) for (const fn of [
12221
12297
  ...test.onFailed
12222
12298
  ].reverse())try {
12223
- await fn({
12224
- task: {
12225
- result
12226
- }
12227
- });
12299
+ await fn(test.context);
12228
12300
  } catch (error) {
12229
12301
  result.errors ??= [];
12230
12302
  result.errors.push(...formatTestError(error));
@@ -12279,7 +12351,9 @@ class TestRunner {
12279
12351
  name: test.name,
12280
12352
  testPath,
12281
12353
  project: test.project,
12282
- testId: test.testId
12354
+ testId: test.testId,
12355
+ type: 'suite',
12356
+ location: test.location
12283
12357
  });
12284
12358
  if (0 === test.tests.length) {
12285
12359
  if ([
@@ -12349,7 +12423,9 @@ class TestRunner {
12349
12423
  name: test.name,
12350
12424
  timeout: test.timeout,
12351
12425
  parentNames: test.parentNames,
12352
- project: test.project
12426
+ project: test.project,
12427
+ type: 'case',
12428
+ location: test.location
12353
12429
  });
12354
12430
  do {
12355
12431
  const currentResult = await runTestsCase(test, parentHooks);
@@ -12429,12 +12505,15 @@ class TestRunner {
12429
12505
  if (unstubEnvs) api.rstest.unstubAllEnvs();
12430
12506
  if (unstubGlobals) api.rstest.unstubAllGlobals();
12431
12507
  }
12432
- createTestContext() {
12508
+ createTestContext(test) {
12433
12509
  const context = ()=>{
12434
12510
  throw new Error('done() callback is deprecated, use promise instead');
12435
12511
  };
12436
12512
  let _expect;
12437
12513
  const current = this._test;
12514
+ context.task = {
12515
+ name: test.name
12516
+ };
12438
12517
  Object.defineProperty(context, 'expect', {
12439
12518
  get: ()=>{
12440
12519
  if (!_expect) _expect = createExpect({
@@ -12490,7 +12569,7 @@ class TestRunner {
12490
12569
  snapshotState,
12491
12570
  currentTestName: getTaskNameWithPrefix(test)
12492
12571
  }, globalThis[GLOBAL_EXPECT]);
12493
- const context = this.createTestContext();
12572
+ const context = this.createTestContext(test);
12494
12573
  const { cleanups } = await handleFixtures(test, context);
12495
12574
  Object.defineProperty(test, 'context', {
12496
12575
  value: context,
@@ -12506,6 +12585,7 @@ class TestRunner {
12506
12585
  if (true === isExpectingAssertions && 0 === assertionCalls) throw isExpectingAssertionsError;
12507
12586
  }
12508
12587
  }
12588
+ const external_node_path_ = __webpack_require__("node:path");
12509
12589
  class RunnerRuntime {
12510
12590
  tests = [];
12511
12591
  _currentTest = [];
@@ -12576,7 +12656,7 @@ class RunnerRuntime {
12576
12656
  type: 'suite'
12577
12657
  };
12578
12658
  }
12579
- describe({ name, fn, runMode = 'run', each = false, concurrent, sequential }) {
12659
+ describe({ name, fn, runMode = 'run', each = false, concurrent, sequential, location }) {
12580
12660
  this.checkStatus(name, 'suite');
12581
12661
  const currentSuite = {
12582
12662
  project: this.project,
@@ -12587,7 +12667,8 @@ class RunnerRuntime {
12587
12667
  each,
12588
12668
  testPath: this.testPath,
12589
12669
  concurrent,
12590
- sequential
12670
+ sequential,
12671
+ location
12591
12672
  };
12592
12673
  if (!fn) {
12593
12674
  this.addTest(currentSuite);
@@ -12656,18 +12737,14 @@ class RunnerRuntime {
12656
12737
  ensureRootSuite() {
12657
12738
  if (0 === this._currentTest.length) this.addTest(this.getDefaultRootSuite());
12658
12739
  }
12659
- it({ name, fn, originalFn = fn, fixtures, timeout = this.runtimeConfig.testTimeout, runMode = 'run', fails = false, each = false, concurrent, sequential }) {
12740
+ it({ name, fn, originalFn = fn, fixtures, timeout = this.runtimeConfig.testTimeout, runMode = 'run', fails = false, each = false, concurrent, sequential, location }) {
12660
12741
  this.checkStatus(name, 'case');
12661
12742
  this.addTestCase({
12662
12743
  project: this.project,
12663
12744
  name,
12664
12745
  originalFn,
12665
- fn: fn ? wrapTimeout({
12666
- name: 'test',
12667
- fn,
12668
- timeout,
12669
- stackTraceError: new Error('STACK_TRACE_ERROR')
12670
- }) : fn,
12746
+ fn,
12747
+ stackTraceError: new Error('STACK_TRACE_ERROR'),
12671
12748
  runMode,
12672
12749
  type: 'case',
12673
12750
  timeout,
@@ -12677,7 +12754,8 @@ class RunnerRuntime {
12677
12754
  each,
12678
12755
  fails,
12679
12756
  onFinished: [],
12680
- onFailed: []
12757
+ onFailed: [],
12758
+ location
12681
12759
  });
12682
12760
  }
12683
12761
  describeEach({ cases, ...options }) {
@@ -12753,12 +12831,33 @@ const createRuntimeAPI = ({ testPath, runtimeConfig, project })=>{
12753
12831
  testPath,
12754
12832
  runtimeConfig
12755
12833
  });
12834
+ const getLocation = ()=>{
12835
+ if (!runtimeConfig.includeTaskLocation) return;
12836
+ const stack = new Error().stack;
12837
+ if (stack) {
12838
+ const frames = parse(stack);
12839
+ for (const frame of frames){
12840
+ let filename = frame.file ?? '';
12841
+ if (filename.startsWith('file://')) filename = fileURLToPath(filename);
12842
+ filename = filename.replaceAll(external_node_path_["default"].sep, '/');
12843
+ if (filename === testPath) {
12844
+ const line = frame.lineNumber;
12845
+ const column = frame.column;
12846
+ if (null != line && null != column) return {
12847
+ line,
12848
+ column
12849
+ };
12850
+ }
12851
+ }
12852
+ }
12853
+ };
12756
12854
  const createTestAPI = (options = {})=>{
12757
12855
  const testFn = (name, fn, timeout)=>runtimeInstance.it({
12758
12856
  name,
12759
12857
  fn,
12760
12858
  timeout,
12761
- ...options
12859
+ ...options,
12860
+ location: options.location ?? getLocation()
12762
12861
  });
12763
12862
  for (const { name, overrides } of [
12764
12863
  {
@@ -12804,15 +12903,25 @@ const createRuntimeAPI = ({ testPath, runtimeConfig, project })=>{
12804
12903
  }),
12805
12904
  enumerable: true
12806
12905
  });
12807
- testFn.runIf = (condition)=>condition ? testFn : testFn.skip;
12808
- testFn.skipIf = (condition)=>condition ? testFn.skip : testFn;
12906
+ testFn.runIf = (condition)=>createTestAPI({
12907
+ ...options,
12908
+ location: getLocation(),
12909
+ runMode: condition ? options.runMode : 'skip'
12910
+ });
12911
+ testFn.skipIf = (condition)=>createTestAPI({
12912
+ ...options,
12913
+ location: getLocation(),
12914
+ runMode: condition ? 'skip' : options.runMode
12915
+ });
12809
12916
  testFn.each = (cases)=>runtimeInstance.each({
12810
12917
  cases,
12811
- ...options
12918
+ ...options,
12919
+ location: getLocation()
12812
12920
  });
12813
12921
  testFn.for = (cases)=>runtimeInstance.for({
12814
12922
  cases,
12815
- ...options
12923
+ ...options,
12924
+ location: getLocation()
12816
12925
  });
12817
12926
  return testFn;
12818
12927
  };
@@ -12832,7 +12941,8 @@ const createRuntimeAPI = ({ testPath, runtimeConfig, project })=>{
12832
12941
  const describeFn = (name, fn)=>runtimeInstance.describe({
12833
12942
  name,
12834
12943
  fn,
12835
- ...options
12944
+ ...options,
12945
+ location: options.location ?? getLocation()
12836
12946
  });
12837
12947
  for (const { name, overrides } of [
12838
12948
  {
@@ -12872,15 +12982,25 @@ const createRuntimeAPI = ({ testPath, runtimeConfig, project })=>{
12872
12982
  }),
12873
12983
  enumerable: true
12874
12984
  });
12875
- describeFn.skipIf = (condition)=>condition ? describeFn.skip : describeFn;
12876
- describeFn.runIf = (condition)=>condition ? describeFn : describeFn.skip;
12985
+ describeFn.skipIf = (condition)=>createDescribeAPI({
12986
+ ...options,
12987
+ location: getLocation(),
12988
+ runMode: condition ? 'skip' : options.runMode
12989
+ });
12990
+ describeFn.runIf = (condition)=>createDescribeAPI({
12991
+ ...options,
12992
+ location: getLocation(),
12993
+ runMode: condition ? options.runMode : 'skip'
12994
+ });
12877
12995
  describeFn.each = (cases)=>runtimeInstance.describeEach({
12878
12996
  cases,
12879
- ...options
12997
+ ...options,
12998
+ location: getLocation()
12880
12999
  });
12881
13000
  describeFn.for = (cases)=>runtimeInstance.describeFor({
12882
13001
  cases,
12883
- ...options
13002
+ ...options,
13003
+ location: getLocation()
12884
13004
  });
12885
13005
  return describeFn;
12886
13006
  };
@@ -12922,6 +13042,21 @@ function createRunner({ workerState }) {
12922
13042
  await snapshotClient.setup(testPath, workerState.snapshotOptions);
12923
13043
  const tests = await runtime.instance.getTests();
12924
13044
  traverseUpdateTest(tests, testNamePattern);
13045
+ hooks.onTestFileReady?.({
13046
+ testPath,
13047
+ tests: tests.map(function toTestInfo(test) {
13048
+ return {
13049
+ testId: test.testId,
13050
+ name: test.name,
13051
+ parentNames: test.parentNames,
13052
+ testPath: test.testPath,
13053
+ project: test.project,
13054
+ type: test.type,
13055
+ location: test.location,
13056
+ tests: 'suite' === test.type ? test.tests.map(toTestInfo) : []
13057
+ };
13058
+ })
13059
+ });
12925
13060
  runtime.instance.updateStatus('running');
12926
13061
  const results = await testRunner.runTests({
12927
13062
  tests,
@@ -12942,7 +13077,7 @@ function createRunner({ workerState }) {
12942
13077
  }
12943
13078
  };
12944
13079
  }
12945
- const fake_timers_src = __webpack_require__("../../node_modules/.pnpm/@sinonjs+fake-timers@14.0.0/node_modules/@sinonjs/fake-timers/src/fake-timers-src.js");
13080
+ const fake_timers_src = __webpack_require__("../../node_modules/.pnpm/@sinonjs+fake-timers@15.0.0/node_modules/@sinonjs/fake-timers/src/fake-timers-src.js");
12946
13081
  const fakeTimers_RealDate = Date;
12947
13082
  class FakeTimers {
12948
13083
  _clock;
@@ -13224,7 +13359,8 @@ const createRstestUtilities = (workerState)=>{
13224
13359
  requireMock: ()=>({}),
13225
13360
  importActual: async ()=>({}),
13226
13361
  requireActual: ()=>({}),
13227
- resetModules: ()=>rstest,
13362
+ resetModules: ()=>({}),
13363
+ hoisted: ()=>({}),
13228
13364
  setConfig: (config)=>{
13229
13365
  if (!originalConfig) originalConfig = {
13230
13366
  ...workerState.runtimeConfig