@vitest/browser 4.0.0-beta.1 → 4.0.0-beta.10

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.
Files changed (42) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +3 -15
  3. package/context.d.ts +153 -3
  4. package/dist/client/.vite/manifest.json +6 -6
  5. package/dist/client/__vitest__/assets/index-DFDJV2DF.js +53 -0
  6. package/dist/client/__vitest__/index.html +1 -1
  7. package/dist/client/__vitest_browser__/orchestrator-BXX6oamz.js +296 -0
  8. package/dist/client/__vitest_browser__/{tester-BScMoGFI.js → tester-CMhJ1E1W.js} +294 -570
  9. package/dist/client/__vitest_browser__/{utils-Owv5OOOf.js → utils-CPmDBIKG.js} +3 -3
  10. package/dist/client/error-catcher.js +7 -3
  11. package/dist/client/esm-client-injector.js +1 -0
  12. package/dist/client/orchestrator.html +2 -2
  13. package/dist/client/tester/tester.html +2 -2
  14. package/dist/client.js +24 -8
  15. package/dist/context.js +29 -22
  16. package/dist/expect-element.js +10 -8
  17. package/dist/index-CwoiDq7G.js +6 -0
  18. package/dist/index-DDlvjJVO.js +1 -0
  19. package/dist/index.d.ts +16 -10
  20. package/dist/index.js +550 -98
  21. package/dist/locators/index.d.ts +8 -7
  22. package/dist/locators/index.js +1 -1
  23. package/dist/locators/playwright.js +1 -1
  24. package/dist/locators/preview.js +1 -1
  25. package/dist/locators/webdriverio.js +1 -1
  26. package/dist/providers/playwright.d.ts +103 -0
  27. package/dist/{webdriver-KA1WiV0q.js → providers/playwright.js} +37 -180
  28. package/dist/providers/preview.d.ts +16 -0
  29. package/dist/{providers.js → providers/preview.js} +17 -21
  30. package/dist/providers/webdriverio.d.ts +50 -0
  31. package/dist/providers/webdriverio.js +171 -0
  32. package/dist/shared/screenshotMatcher/types.d.ts +16 -0
  33. package/dist/state.js +4 -2
  34. package/dist/types.d.ts +5 -7
  35. package/jest-dom.d.ts +95 -1
  36. package/package.json +20 -30
  37. package/utils.d.ts +1 -1
  38. package/dist/client/__vitest__/assets/index-BjtzXzAw.js +0 -58
  39. package/dist/client/__vitest_browser__/orchestrator-CQgVbcQq.js +0 -3213
  40. package/dist/index-W1MM53zC.js +0 -1
  41. package/providers/playwright.d.ts +0 -81
  42. package/providers/webdriverio.d.ts +0 -22
@@ -1,10 +1,10 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { b as resolve, e as executor, c as getWorkerState, a as getConfig, g as getBrowserState } from "./utils-Owv5OOOf.js";
4
+ import { b as resolve, m as moduleRunner, c as getWorkerState, a as getConfig, g as getBrowserState } from "./utils-CPmDBIKG.js";
5
5
  import { onCancel, globalChannel, channel, client } from "@vitest/browser/client";
6
6
  import { userEvent, page, server } from "@vitest/browser/context";
7
- import { getSafeTimers, TraceMap, originalPositionFor, loadDiffConfig, loadSnapshotSerializers, takeCoverageInsideWorker, stringify, format, setupCommonEnv, startCoverageInsideWorker, stopCoverageInsideWorker, startTests, collectTests, SpyModule } from "vitest/internal/browser";
7
+ import { getSafeTimers, TraceMap as TraceMap$1, originalPositionFor as originalPositionFor$1, loadDiffConfig, loadSnapshotSerializers, takeCoverageInsideWorker, stringify, format, setupCommonEnv, startCoverageInsideWorker, stopCoverageInsideWorker, startTests, collectTests, SpyModule } from "vitest/internal/browser";
8
8
  import { VitestTestRunner, NodeBenchmarkRunner } from "vitest/runners";
9
9
  const scriptRel = "modulepreload";
10
10
  const assetsURL = function(dep) {
@@ -111,7 +111,7 @@ const revive = (input, parsed, output, $) => {
111
111
  }
112
112
  return output;
113
113
  };
114
- const parse = (text, reviver) => {
114
+ const parse$1 = (text, reviver) => {
115
115
  const input = $parse(text, Primitives).map(primitives);
116
116
  const value = input[0];
117
117
  const $ = noop;
@@ -179,7 +179,9 @@ function createSafeRpc(client2) {
179
179
  function rpc$2() {
180
180
  return globalThis.__vitest_worker__.rpc;
181
181
  }
182
- var traceMapping_umd$1 = { exports: {} };
182
+ function getDefaultExportFromCjs$1(x) {
183
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
184
+ }
183
185
  var sourcemapCodec_umd$1 = { exports: {} };
184
186
  var sourcemapCodec_umd = sourcemapCodec_umd$1.exports;
185
187
  var hasRequiredSourcemapCodec_umd;
@@ -561,9 +563,9 @@ function requireSourcemapCodec_umd() {
561
563
  return decoded;
562
564
  }
563
565
  function sort(line) {
564
- line.sort(sortComparator);
566
+ line.sort(sortComparator2);
565
567
  }
566
- function sortComparator(a2, b) {
568
+ function sortComparator2(a2, b) {
567
569
  return a2[0] - b[0];
568
570
  }
569
571
  function encode(decoded) {
@@ -607,6 +609,7 @@ function requireSourcemapCodec_umd() {
607
609
  })(sourcemapCodec_umd$1, sourcemapCodec_umd$1.exports);
608
610
  return sourcemapCodec_umd$1.exports;
609
611
  }
612
+ var sourcemapCodec_umdExports = requireSourcemapCodec_umd();
610
613
  var resolveUri_umd$1 = { exports: {} };
611
614
  var resolveUri_umd = resolveUri_umd$1.exports;
612
615
  var hasRequiredResolveUri_umd;
@@ -799,485 +802,192 @@ function requireResolveUri_umd() {
799
802
  })(resolveUri_umd$1);
800
803
  return resolveUri_umd$1.exports;
801
804
  }
802
- var traceMapping_umd = traceMapping_umd$1.exports;
803
- var hasRequiredTraceMapping_umd;
804
- function requireTraceMapping_umd() {
805
- if (hasRequiredTraceMapping_umd) return traceMapping_umd$1.exports;
806
- hasRequiredTraceMapping_umd = 1;
807
- (function(module, exports) {
808
- (function(global, factory) {
809
- factory(exports, requireSourcemapCodec_umd(), requireResolveUri_umd());
810
- })(traceMapping_umd, function(exports2, sourcemapCodec, resolveUri) {
811
- function resolve2(input, base) {
812
- if (base && !base.endsWith("/"))
813
- base += "/";
814
- return resolveUri(input, base);
815
- }
816
- function stripFilename(path) {
817
- if (!path)
818
- return "";
819
- const index2 = path.lastIndexOf("/");
820
- return path.slice(0, index2 + 1);
821
- }
822
- const COLUMN = 0;
823
- const SOURCES_INDEX = 1;
824
- const SOURCE_LINE = 2;
825
- const SOURCE_COLUMN = 3;
826
- const NAMES_INDEX = 4;
827
- const REV_GENERATED_LINE = 1;
828
- const REV_GENERATED_COLUMN = 2;
829
- function maybeSort(mappings, owned) {
830
- const unsortedIndex = nextUnsortedSegmentLine(mappings, 0);
831
- if (unsortedIndex === mappings.length)
832
- return mappings;
833
- if (!owned)
834
- mappings = mappings.slice();
835
- for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) {
836
- mappings[i] = sortSegments(mappings[i], owned);
837
- }
838
- return mappings;
839
- }
840
- function nextUnsortedSegmentLine(mappings, start) {
841
- for (let i = start; i < mappings.length; i++) {
842
- if (!isSorted(mappings[i]))
843
- return i;
844
- }
845
- return mappings.length;
846
- }
847
- function isSorted(line) {
848
- for (let j = 1; j < line.length; j++) {
849
- if (line[j][COLUMN] < line[j - 1][COLUMN]) {
850
- return false;
851
- }
852
- }
853
- return true;
854
- }
855
- function sortSegments(line, owned) {
856
- if (!owned)
857
- line = line.slice();
858
- return line.sort(sortComparator);
859
- }
860
- function sortComparator(a2, b) {
861
- return a2[COLUMN] - b[COLUMN];
862
- }
863
- let found = false;
864
- function binarySearch(haystack, needle, low, high) {
865
- while (low <= high) {
866
- const mid = low + (high - low >> 1);
867
- const cmp = haystack[mid][COLUMN] - needle;
868
- if (cmp === 0) {
869
- found = true;
870
- return mid;
871
- }
872
- if (cmp < 0) {
873
- low = mid + 1;
874
- } else {
875
- high = mid - 1;
876
- }
877
- }
878
- found = false;
879
- return low - 1;
880
- }
881
- function upperBound(haystack, needle, index2) {
882
- for (let i = index2 + 1; i < haystack.length; index2 = i++) {
883
- if (haystack[i][COLUMN] !== needle)
884
- break;
885
- }
886
- return index2;
887
- }
888
- function lowerBound(haystack, needle, index2) {
889
- for (let i = index2 - 1; i >= 0; index2 = i--) {
890
- if (haystack[i][COLUMN] !== needle)
891
- break;
892
- }
893
- return index2;
894
- }
895
- function memoizedState() {
896
- return {
897
- lastKey: -1,
898
- lastNeedle: -1,
899
- lastIndex: -1
900
- };
901
- }
902
- function memoizedBinarySearch(haystack, needle, state, key) {
903
- const { lastKey, lastNeedle, lastIndex } = state;
904
- let low = 0;
905
- let high = haystack.length - 1;
906
- if (key === lastKey) {
907
- if (needle === lastNeedle) {
908
- found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle;
909
- return lastIndex;
910
- }
911
- if (needle >= lastNeedle) {
912
- low = lastIndex === -1 ? 0 : lastIndex;
913
- } else {
914
- high = lastIndex;
915
- }
916
- }
917
- state.lastKey = key;
918
- state.lastNeedle = needle;
919
- return state.lastIndex = binarySearch(haystack, needle, low, high);
920
- }
921
- function buildBySources(decoded, memos) {
922
- const sources = memos.map(buildNullArray);
923
- for (let i = 0; i < decoded.length; i++) {
924
- const line = decoded[i];
925
- for (let j = 0; j < line.length; j++) {
926
- const seg = line[j];
927
- if (seg.length === 1)
928
- continue;
929
- const sourceIndex2 = seg[SOURCES_INDEX];
930
- const sourceLine = seg[SOURCE_LINE];
931
- const sourceColumn = seg[SOURCE_COLUMN];
932
- const originalSource = sources[sourceIndex2];
933
- const originalLine = originalSource[sourceLine] || (originalSource[sourceLine] = []);
934
- const memo = memos[sourceIndex2];
935
- let index2 = upperBound(originalLine, sourceColumn, memoizedBinarySearch(originalLine, sourceColumn, memo, sourceLine));
936
- memo.lastIndex = ++index2;
937
- insert(originalLine, index2, [sourceColumn, i, seg[COLUMN]]);
938
- }
939
- }
940
- return sources;
941
- }
942
- function insert(array, index2, value) {
943
- for (let i = array.length; i > index2; i--) {
944
- array[i] = array[i - 1];
945
- }
946
- array[index2] = value;
947
- }
948
- function buildNullArray() {
949
- return { __proto__: null };
950
- }
951
- const AnyMap = function(map, mapUrl) {
952
- const parsed = parse2(map);
953
- if (!("sections" in parsed)) {
954
- return new TraceMap2(parsed, mapUrl);
955
- }
956
- const mappings = [];
957
- const sources = [];
958
- const sourcesContent = [];
959
- const names = [];
960
- const ignoreList = [];
961
- recurse(parsed, mapUrl, mappings, sources, sourcesContent, names, ignoreList, 0, 0, Infinity, Infinity);
962
- const joined = {
963
- version: 3,
964
- file: parsed.file,
965
- names,
966
- sources,
967
- sourcesContent,
968
- mappings,
969
- ignoreList
970
- };
971
- return presortedDecodedMap(joined);
972
- };
973
- function parse2(map) {
974
- return typeof map === "string" ? JSON.parse(map) : map;
975
- }
976
- function recurse(input, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) {
977
- const { sections } = input;
978
- for (let i = 0; i < sections.length; i++) {
979
- const { map, offset } = sections[i];
980
- let sl = stopLine;
981
- let sc = stopColumn;
982
- if (i + 1 < sections.length) {
983
- const nextOffset = sections[i + 1].offset;
984
- sl = Math.min(stopLine, lineOffset + nextOffset.line);
985
- if (sl === stopLine) {
986
- sc = Math.min(stopColumn, columnOffset + nextOffset.column);
987
- } else if (sl < stopLine) {
988
- sc = columnOffset + nextOffset.column;
989
- }
990
- }
991
- addSection(map, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset + offset.line, columnOffset + offset.column, sl, sc);
992
- }
993
- }
994
- function addSection(input, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) {
995
- const parsed = parse2(input);
996
- if ("sections" in parsed)
997
- return recurse(...arguments);
998
- const map = new TraceMap2(parsed, mapUrl);
999
- const sourcesOffset = sources.length;
1000
- const namesOffset = names.length;
1001
- const decoded = decodedMappings(map);
1002
- const { resolvedSources, sourcesContent: contents, ignoreList: ignores } = map;
1003
- append(sources, resolvedSources);
1004
- append(names, map.names);
1005
- if (contents)
1006
- append(sourcesContent, contents);
1007
- else
1008
- for (let i = 0; i < resolvedSources.length; i++)
1009
- sourcesContent.push(null);
1010
- if (ignores)
1011
- for (let i = 0; i < ignores.length; i++)
1012
- ignoreList.push(ignores[i] + sourcesOffset);
1013
- for (let i = 0; i < decoded.length; i++) {
1014
- const lineI = lineOffset + i;
1015
- if (lineI > stopLine)
1016
- return;
1017
- const out = getLine(mappings, lineI);
1018
- const cOffset = i === 0 ? columnOffset : 0;
1019
- const line = decoded[i];
1020
- for (let j = 0; j < line.length; j++) {
1021
- const seg = line[j];
1022
- const column = cOffset + seg[COLUMN];
1023
- if (lineI === stopLine && column >= stopColumn)
1024
- return;
1025
- if (seg.length === 1) {
1026
- out.push([column]);
1027
- continue;
1028
- }
1029
- const sourcesIndex = sourcesOffset + seg[SOURCES_INDEX];
1030
- const sourceLine = seg[SOURCE_LINE];
1031
- const sourceColumn = seg[SOURCE_COLUMN];
1032
- out.push(seg.length === 4 ? [column, sourcesIndex, sourceLine, sourceColumn] : [column, sourcesIndex, sourceLine, sourceColumn, namesOffset + seg[NAMES_INDEX]]);
1033
- }
1034
- }
1035
- }
1036
- function append(arr, other) {
1037
- for (let i = 0; i < other.length; i++)
1038
- arr.push(other[i]);
1039
- }
1040
- function getLine(arr, index2) {
1041
- for (let i = arr.length; i <= index2; i++)
1042
- arr[i] = [];
1043
- return arr[index2];
1044
- }
1045
- const LINE_GTR_ZERO = "`line` must be greater than 0 (lines start at line 1)";
1046
- const COL_GTR_EQ_ZERO = "`column` must be greater than or equal to 0 (columns start at column 0)";
1047
- const LEAST_UPPER_BOUND = -1;
1048
- const GREATEST_LOWER_BOUND = 1;
1049
- class TraceMap2 {
1050
- constructor(map, mapUrl) {
1051
- const isString = typeof map === "string";
1052
- if (!isString && map._decodedMemo)
1053
- return map;
1054
- const parsed = isString ? JSON.parse(map) : map;
1055
- const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
1056
- this.version = version;
1057
- this.file = file;
1058
- this.names = names || [];
1059
- this.sourceRoot = sourceRoot;
1060
- this.sources = sources;
1061
- this.sourcesContent = sourcesContent;
1062
- this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0;
1063
- const from = resolve2(sourceRoot || "", stripFilename(mapUrl));
1064
- this.resolvedSources = sources.map((s) => resolve2(s || "", from));
1065
- const { mappings } = parsed;
1066
- if (typeof mappings === "string") {
1067
- this._encoded = mappings;
1068
- this._decoded = void 0;
1069
- } else {
1070
- this._encoded = void 0;
1071
- this._decoded = maybeSort(mappings, isString);
1072
- }
1073
- this._decodedMemo = memoizedState();
1074
- this._bySources = void 0;
1075
- this._bySourceMemos = void 0;
1076
- }
1077
- }
1078
- function cast(map) {
1079
- return map;
1080
- }
1081
- function encodedMappings(map) {
1082
- var _a;
1083
- var _b;
1084
- return (_a = (_b = cast(map))._encoded) !== null && _a !== void 0 ? _a : _b._encoded = sourcemapCodec.encode(cast(map)._decoded);
1085
- }
1086
- function decodedMappings(map) {
1087
- var _a;
1088
- return (_a = cast(map))._decoded || (_a._decoded = sourcemapCodec.decode(cast(map)._encoded));
1089
- }
1090
- function traceSegment(map, line, column) {
1091
- const decoded = decodedMappings(map);
1092
- if (line >= decoded.length)
1093
- return null;
1094
- const segments = decoded[line];
1095
- const index2 = traceSegmentInternal(segments, cast(map)._decodedMemo, line, column, GREATEST_LOWER_BOUND);
1096
- return index2 === -1 ? null : segments[index2];
1097
- }
1098
- function originalPositionFor2(map, needle) {
1099
- let { line, column, bias } = needle;
1100
- line--;
1101
- if (line < 0)
1102
- throw new Error(LINE_GTR_ZERO);
1103
- if (column < 0)
1104
- throw new Error(COL_GTR_EQ_ZERO);
1105
- const decoded = decodedMappings(map);
1106
- if (line >= decoded.length)
1107
- return OMapping(null, null, null, null);
1108
- const segments = decoded[line];
1109
- const index2 = traceSegmentInternal(segments, cast(map)._decodedMemo, line, column, bias || GREATEST_LOWER_BOUND);
1110
- if (index2 === -1)
1111
- return OMapping(null, null, null, null);
1112
- const segment = segments[index2];
1113
- if (segment.length === 1)
1114
- return OMapping(null, null, null, null);
1115
- const { names, resolvedSources } = map;
1116
- return OMapping(resolvedSources[segment[SOURCES_INDEX]], segment[SOURCE_LINE] + 1, segment[SOURCE_COLUMN], segment.length === 5 ? names[segment[NAMES_INDEX]] : null);
1117
- }
1118
- function generatedPositionFor(map, needle) {
1119
- const { source, line, column, bias } = needle;
1120
- return generatedPosition(map, source, line, column, bias || GREATEST_LOWER_BOUND, false);
1121
- }
1122
- function allGeneratedPositionsFor(map, needle) {
1123
- const { source, line, column, bias } = needle;
1124
- return generatedPosition(map, source, line, column, bias || LEAST_UPPER_BOUND, true);
1125
- }
1126
- function eachMapping(map, cb) {
1127
- const decoded = decodedMappings(map);
1128
- const { names, resolvedSources } = map;
1129
- for (let i = 0; i < decoded.length; i++) {
1130
- const line = decoded[i];
1131
- for (let j = 0; j < line.length; j++) {
1132
- const seg = line[j];
1133
- const generatedLine = i + 1;
1134
- const generatedColumn = seg[0];
1135
- let source = null;
1136
- let originalLine = null;
1137
- let originalColumn = null;
1138
- let name = null;
1139
- if (seg.length !== 1) {
1140
- source = resolvedSources[seg[1]];
1141
- originalLine = seg[2] + 1;
1142
- originalColumn = seg[3];
1143
- }
1144
- if (seg.length === 5)
1145
- name = names[seg[4]];
1146
- cb({
1147
- generatedLine,
1148
- generatedColumn,
1149
- source,
1150
- originalLine,
1151
- originalColumn,
1152
- name
1153
- });
1154
- }
1155
- }
1156
- }
1157
- function sourceIndex(map, source) {
1158
- const { sources, resolvedSources } = map;
1159
- let index2 = sources.indexOf(source);
1160
- if (index2 === -1)
1161
- index2 = resolvedSources.indexOf(source);
1162
- return index2;
1163
- }
1164
- function sourceContentFor(map, source) {
1165
- const { sourcesContent } = map;
1166
- if (sourcesContent == null)
1167
- return null;
1168
- const index2 = sourceIndex(map, source);
1169
- return index2 === -1 ? null : sourcesContent[index2];
1170
- }
1171
- function isIgnored(map, source) {
1172
- const { ignoreList } = map;
1173
- if (ignoreList == null)
1174
- return false;
1175
- const index2 = sourceIndex(map, source);
1176
- return index2 === -1 ? false : ignoreList.includes(index2);
1177
- }
1178
- function presortedDecodedMap(map, mapUrl) {
1179
- const tracer = new TraceMap2(clone(map, []), mapUrl);
1180
- cast(tracer)._decoded = map.mappings;
1181
- return tracer;
1182
- }
1183
- function decodedMap(map) {
1184
- return clone(map, decodedMappings(map));
1185
- }
1186
- function encodedMap(map) {
1187
- return clone(map, encodedMappings(map));
1188
- }
1189
- function clone(map, mappings) {
1190
- return {
1191
- version: map.version,
1192
- file: map.file,
1193
- names: map.names,
1194
- sourceRoot: map.sourceRoot,
1195
- sources: map.sources,
1196
- sourcesContent: map.sourcesContent,
1197
- mappings,
1198
- ignoreList: map.ignoreList || map.x_google_ignoreList
1199
- };
1200
- }
1201
- function OMapping(source, line, column, name) {
1202
- return { source, line, column, name };
1203
- }
1204
- function GMapping(line, column) {
1205
- return { line, column };
1206
- }
1207
- function traceSegmentInternal(segments, memo, line, column, bias) {
1208
- let index2 = memoizedBinarySearch(segments, column, memo, line);
1209
- if (found) {
1210
- index2 = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index2);
1211
- } else if (bias === LEAST_UPPER_BOUND)
1212
- index2++;
1213
- if (index2 === -1 || index2 === segments.length)
1214
- return -1;
1215
- return index2;
1216
- }
1217
- function sliceGeneratedPositions(segments, memo, line, column, bias) {
1218
- let min = traceSegmentInternal(segments, memo, line, column, GREATEST_LOWER_BOUND);
1219
- if (!found && bias === LEAST_UPPER_BOUND)
1220
- min++;
1221
- if (min === -1 || min === segments.length)
1222
- return [];
1223
- const matchedColumn = found ? column : segments[min][COLUMN];
1224
- if (!found)
1225
- min = lowerBound(segments, matchedColumn, min);
1226
- const max = upperBound(segments, matchedColumn, min);
1227
- const result = [];
1228
- for (; min <= max; min++) {
1229
- const segment = segments[min];
1230
- result.push(GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]));
1231
- }
1232
- return result;
1233
- }
1234
- function generatedPosition(map, source, line, column, bias, all) {
1235
- var _a;
1236
- line--;
1237
- if (line < 0)
1238
- throw new Error(LINE_GTR_ZERO);
1239
- if (column < 0)
1240
- throw new Error(COL_GTR_EQ_ZERO);
1241
- const { sources, resolvedSources } = map;
1242
- let sourceIndex2 = sources.indexOf(source);
1243
- if (sourceIndex2 === -1)
1244
- sourceIndex2 = resolvedSources.indexOf(source);
1245
- if (sourceIndex2 === -1)
1246
- return all ? [] : GMapping(null, null);
1247
- const generated = (_a = cast(map))._bySources || (_a._bySources = buildBySources(decodedMappings(map), cast(map)._bySourceMemos = sources.map(memoizedState)));
1248
- const segments = generated[sourceIndex2][line];
1249
- if (segments == null)
1250
- return all ? [] : GMapping(null, null);
1251
- const memo = cast(map)._bySourceMemos[sourceIndex2];
1252
- if (all)
1253
- return sliceGeneratedPositions(segments, memo, line, column, bias);
1254
- const index2 = traceSegmentInternal(segments, memo, line, column, bias);
1255
- if (index2 === -1)
1256
- return GMapping(null, null);
1257
- const segment = segments[index2];
1258
- return GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]);
1259
- }
1260
- exports2.AnyMap = AnyMap;
1261
- exports2.GREATEST_LOWER_BOUND = GREATEST_LOWER_BOUND;
1262
- exports2.LEAST_UPPER_BOUND = LEAST_UPPER_BOUND;
1263
- exports2.TraceMap = TraceMap2;
1264
- exports2.allGeneratedPositionsFor = allGeneratedPositionsFor;
1265
- exports2.decodedMap = decodedMap;
1266
- exports2.decodedMappings = decodedMappings;
1267
- exports2.eachMapping = eachMapping;
1268
- exports2.encodedMap = encodedMap;
1269
- exports2.encodedMappings = encodedMappings;
1270
- exports2.generatedPositionFor = generatedPositionFor;
1271
- exports2.isIgnored = isIgnored;
1272
- exports2.originalPositionFor = originalPositionFor2;
1273
- exports2.presortedDecodedMap = presortedDecodedMap;
1274
- exports2.sourceContentFor = sourceContentFor;
1275
- exports2.traceSegment = traceSegment;
1276
- });
1277
- })(traceMapping_umd$1, traceMapping_umd$1.exports);
1278
- return traceMapping_umd$1.exports;
805
+ var resolveUri_umdExports = requireResolveUri_umd();
806
+ const resolveUri = /* @__PURE__ */ getDefaultExportFromCjs$1(resolveUri_umdExports);
807
+ function stripFilename(path) {
808
+ if (!path) return "";
809
+ const index2 = path.lastIndexOf("/");
810
+ return path.slice(0, index2 + 1);
811
+ }
812
+ function resolver(mapUrl, sourceRoot) {
813
+ const from = stripFilename(mapUrl);
814
+ const prefix = sourceRoot ? sourceRoot + "/" : "";
815
+ return (source) => resolveUri(prefix + (source || ""), from);
816
+ }
817
+ var COLUMN = 0;
818
+ var SOURCES_INDEX = 1;
819
+ var SOURCE_LINE = 2;
820
+ var SOURCE_COLUMN = 3;
821
+ var NAMES_INDEX = 4;
822
+ function maybeSort(mappings, owned) {
823
+ const unsortedIndex = nextUnsortedSegmentLine(mappings, 0);
824
+ if (unsortedIndex === mappings.length) return mappings;
825
+ if (!owned) mappings = mappings.slice();
826
+ for (let i = unsortedIndex; i < mappings.length; i = nextUnsortedSegmentLine(mappings, i + 1)) {
827
+ mappings[i] = sortSegments(mappings[i], owned);
828
+ }
829
+ return mappings;
830
+ }
831
+ function nextUnsortedSegmentLine(mappings, start) {
832
+ for (let i = start; i < mappings.length; i++) {
833
+ if (!isSorted(mappings[i])) return i;
834
+ }
835
+ return mappings.length;
836
+ }
837
+ function isSorted(line) {
838
+ for (let j = 1; j < line.length; j++) {
839
+ if (line[j][COLUMN] < line[j - 1][COLUMN]) {
840
+ return false;
841
+ }
842
+ }
843
+ return true;
844
+ }
845
+ function sortSegments(line, owned) {
846
+ if (!owned) line = line.slice();
847
+ return line.sort(sortComparator);
848
+ }
849
+ function sortComparator(a2, b) {
850
+ return a2[COLUMN] - b[COLUMN];
851
+ }
852
+ var found = false;
853
+ function binarySearch(haystack, needle, low, high) {
854
+ while (low <= high) {
855
+ const mid = low + (high - low >> 1);
856
+ const cmp = haystack[mid][COLUMN] - needle;
857
+ if (cmp === 0) {
858
+ found = true;
859
+ return mid;
860
+ }
861
+ if (cmp < 0) {
862
+ low = mid + 1;
863
+ } else {
864
+ high = mid - 1;
865
+ }
866
+ }
867
+ found = false;
868
+ return low - 1;
869
+ }
870
+ function upperBound(haystack, needle, index2) {
871
+ for (let i = index2 + 1; i < haystack.length; index2 = i++) {
872
+ if (haystack[i][COLUMN] !== needle) break;
873
+ }
874
+ return index2;
875
+ }
876
+ function lowerBound(haystack, needle, index2) {
877
+ for (let i = index2 - 1; i >= 0; index2 = i--) {
878
+ if (haystack[i][COLUMN] !== needle) break;
879
+ }
880
+ return index2;
881
+ }
882
+ function memoizedState() {
883
+ return {
884
+ lastKey: -1,
885
+ lastNeedle: -1,
886
+ lastIndex: -1
887
+ };
888
+ }
889
+ function memoizedBinarySearch(haystack, needle, state, key) {
890
+ const { lastKey, lastNeedle, lastIndex } = state;
891
+ let low = 0;
892
+ let high = haystack.length - 1;
893
+ if (key === lastKey) {
894
+ if (needle === lastNeedle) {
895
+ found = lastIndex !== -1 && haystack[lastIndex][COLUMN] === needle;
896
+ return lastIndex;
897
+ }
898
+ if (needle >= lastNeedle) {
899
+ low = lastIndex === -1 ? 0 : lastIndex;
900
+ } else {
901
+ high = lastIndex;
902
+ }
903
+ }
904
+ state.lastKey = key;
905
+ state.lastNeedle = needle;
906
+ return state.lastIndex = binarySearch(haystack, needle, low, high);
907
+ }
908
+ function parse(map) {
909
+ return typeof map === "string" ? JSON.parse(map) : map;
910
+ }
911
+ var LINE_GTR_ZERO = "`line` must be greater than 0 (lines start at line 1)";
912
+ var COL_GTR_EQ_ZERO = "`column` must be greater than or equal to 0 (columns start at column 0)";
913
+ var LEAST_UPPER_BOUND = -1;
914
+ var GREATEST_LOWER_BOUND = 1;
915
+ var TraceMap = class {
916
+ constructor(map, mapUrl) {
917
+ const isString = typeof map === "string";
918
+ if (!isString && map._decodedMemo) return map;
919
+ const parsed = parse(map);
920
+ const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
921
+ this.version = version;
922
+ this.file = file;
923
+ this.names = names || [];
924
+ this.sourceRoot = sourceRoot;
925
+ this.sources = sources;
926
+ this.sourcesContent = sourcesContent;
927
+ this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0;
928
+ const resolve2 = resolver(mapUrl, sourceRoot);
929
+ this.resolvedSources = sources.map(resolve2);
930
+ const { mappings } = parsed;
931
+ if (typeof mappings === "string") {
932
+ this._encoded = mappings;
933
+ this._decoded = void 0;
934
+ } else if (Array.isArray(mappings)) {
935
+ this._encoded = void 0;
936
+ this._decoded = maybeSort(mappings, isString);
937
+ } else if (parsed.sections) {
938
+ throw new Error(`TraceMap passed sectioned source map, please use FlattenMap export instead`);
939
+ } else {
940
+ throw new Error(`invalid source map: ${JSON.stringify(parsed)}`);
941
+ }
942
+ this._decodedMemo = memoizedState();
943
+ this._bySources = void 0;
944
+ this._bySourceMemos = void 0;
945
+ }
946
+ };
947
+ function cast(map) {
948
+ return map;
949
+ }
950
+ function decodedMappings(map) {
951
+ var _a;
952
+ return (_a = cast(map))._decoded || (_a._decoded = sourcemapCodec_umdExports.decode(cast(map)._encoded));
953
+ }
954
+ function originalPositionFor(map, needle) {
955
+ let { line, column, bias } = needle;
956
+ line--;
957
+ if (line < 0) throw new Error(LINE_GTR_ZERO);
958
+ if (column < 0) throw new Error(COL_GTR_EQ_ZERO);
959
+ const decoded = decodedMappings(map);
960
+ if (line >= decoded.length) return OMapping(null, null, null, null);
961
+ const segments = decoded[line];
962
+ const index2 = traceSegmentInternal(
963
+ segments,
964
+ cast(map)._decodedMemo,
965
+ line,
966
+ column,
967
+ bias || GREATEST_LOWER_BOUND
968
+ );
969
+ if (index2 === -1) return OMapping(null, null, null, null);
970
+ const segment = segments[index2];
971
+ if (segment.length === 1) return OMapping(null, null, null, null);
972
+ const { names, resolvedSources } = map;
973
+ return OMapping(
974
+ resolvedSources[segment[SOURCES_INDEX]],
975
+ segment[SOURCE_LINE] + 1,
976
+ segment[SOURCE_COLUMN],
977
+ segment.length === 5 ? names[segment[NAMES_INDEX]] : null
978
+ );
979
+ }
980
+ function OMapping(source, line, column, name) {
981
+ return { source, line, column, name };
982
+ }
983
+ function traceSegmentInternal(segments, memo, line, column, bias) {
984
+ let index2 = memoizedBinarySearch(segments, column, memo, line);
985
+ if (found) {
986
+ index2 = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index2);
987
+ } else if (bias === LEAST_UPPER_BOUND) index2++;
988
+ if (index2 === -1 || index2 === segments.length) return -1;
989
+ return index2;
1279
990
  }
1280
- var traceMapping_umdExports = requireTraceMapping_umd();
1281
991
  function notNullish(v) {
1282
992
  return v != null;
1283
993
  }
@@ -1294,6 +1004,8 @@ const stackIgnorePatterns = [
1294
1004
  "/node_modules/chai/",
1295
1005
  "/node_modules/tinypool/",
1296
1006
  "/node_modules/tinyspy/",
1007
+ "/vite/dist/node/module-runner",
1008
+ "/rolldown-vite/dist/node/module-runner",
1297
1009
  // browser related deps
1298
1010
  "/deps/chunk-",
1299
1011
  "/deps/@vitest",
@@ -1416,8 +1128,8 @@ function parseStacktrace(stack, options = {}) {
1416
1128
  if (!map || typeof map !== "object" || !map.version) {
1417
1129
  return shouldFilter(ignoreStackEntries, stack2.file) ? null : stack2;
1418
1130
  }
1419
- const traceMap = new traceMapping_umdExports.TraceMap(map);
1420
- const { line, column, source, name } = traceMapping_umdExports.originalPositionFor(traceMap, stack2);
1131
+ const traceMap = new TraceMap(map);
1132
+ const { line, column, source, name } = originalPositionFor(traceMap, stack2);
1421
1133
  let file = stack2.file;
1422
1134
  if (source) {
1423
1135
  const fileUrl = stack2.file.startsWith("file://") ? stack2.file : `file://${stack2.file}`;
@@ -1486,10 +1198,10 @@ class VitestBrowserSnapshotEnvironment {
1486
1198
  }
1487
1199
  let traceMap = this.traceMaps.get(stack.file);
1488
1200
  if (!traceMap) {
1489
- traceMap = new TraceMap(map);
1201
+ traceMap = new TraceMap$1(map);
1490
1202
  this.traceMaps.set(stack.file, traceMap);
1491
1203
  }
1492
- const { line, column } = originalPositionFor(traceMap, stack);
1204
+ const { line, column } = originalPositionFor$1(traceMap, stack);
1493
1205
  if (line != null && column != null) {
1494
1206
  return { ...stack, line, column };
1495
1207
  }
@@ -1573,7 +1285,7 @@ function createBrowserRunner(runnerClass, mocker, state, coverageModule) {
1573
1285
  await rpc$2().onAfterSuiteRun({
1574
1286
  coverage,
1575
1287
  testFiles: files.map((file) => file.name),
1576
- transformMode: "browser",
1288
+ environment: "__browser__",
1577
1289
  projectName: this.config.name
1578
1290
  });
1579
1291
  }
@@ -1602,8 +1314,8 @@ function createBrowserRunner(runnerClass, mocker, state, coverageModule) {
1602
1314
  if (!map) {
1603
1315
  return rpc$2().onTaskAnnotate(test.id, annotation);
1604
1316
  }
1605
- const traceMap = new TraceMap(map);
1606
- const { line, column, source } = originalPositionFor(traceMap, annotation.location);
1317
+ const traceMap = new TraceMap$1(map);
1318
+ const { line, column, source } = originalPositionFor$1(traceMap, annotation.location);
1607
1319
  if (line != null && column != null && source != null) {
1608
1320
  let file = annotation.location.file;
1609
1321
  if (source) {
@@ -1659,7 +1371,7 @@ async function initiateRunner(state, mocker, config) {
1659
1371
  }
1660
1372
  const runnerClass = config.mode === "test" ? VitestTestRunner : NodeBenchmarkRunner;
1661
1373
  const BrowserRunner = createBrowserRunner(runnerClass, mocker, state, {
1662
- takeCoverage: () => takeCoverageInsideWorker(config.coverage, executor)
1374
+ takeCoverage: () => takeCoverageInsideWorker(config.coverage, moduleRunner)
1663
1375
  });
1664
1376
  if (!config.snapshotOptions.snapshotEnvironment) {
1665
1377
  config.snapshotOptions.snapshotEnvironment = new VitestBrowserSnapshotEnvironment();
@@ -1673,8 +1385,8 @@ async function initiateRunner(state, mocker, config) {
1673
1385
  (_a = runner.cancel) == null ? void 0 : _a.call(runner, reason);
1674
1386
  });
1675
1387
  const [diffOptions] = await Promise.all([
1676
- loadDiffConfig(config, executor),
1677
- loadSnapshotSerializers(config, executor)
1388
+ loadDiffConfig(config, moduleRunner),
1389
+ loadSnapshotSerializers(config, moduleRunner)
1678
1390
  ]);
1679
1391
  runner.config.diffOptions = diffOptions;
1680
1392
  getWorkerState().onFilterStackTrace = (stack) => {
@@ -1695,7 +1407,7 @@ async function getTraceMap(file, sourceMaps) {
1695
1407
  if (!result) {
1696
1408
  return null;
1697
1409
  }
1698
- return new TraceMap(result);
1410
+ return new TraceMap$1(result);
1699
1411
  }
1700
1412
  async function updateTestFilesLocations(files, sourceMaps) {
1701
1413
  const promises2 = files.map(async (file) => {
@@ -1705,7 +1417,7 @@ async function updateTestFilesLocations(files, sourceMaps) {
1705
1417
  }
1706
1418
  const updateLocation = (task) => {
1707
1419
  if (task.location) {
1708
- const { line, column } = originalPositionFor(traceMap, task.location);
1420
+ const { line, column } = originalPositionFor$1(traceMap, task.location);
1709
1421
  if (line != null && column != null) {
1710
1422
  task.location = { line, column: task.each ? column : column + 1 };
1711
1423
  }
@@ -1919,6 +1631,9 @@ class MockerRegistry {
1919
1631
  delete(id) {
1920
1632
  this.registryByUrl.delete(id);
1921
1633
  }
1634
+ deleteById(id) {
1635
+ this.registryById.delete(id);
1636
+ }
1922
1637
  get(id) {
1923
1638
  return this.registryByUrl.get(id);
1924
1639
  }
@@ -2037,18 +1752,42 @@ function mockObject(options, object2, mockExports = {}) {
2037
1752
  return false;
2038
1753
  }
2039
1754
  };
1755
+ const createMock = (currentValue) => {
1756
+ if (!options.createMockInstance) {
1757
+ throw new Error("[@vitest/mocker] `createMockInstance` is not defined. This is a Vitest error. Please open a new issue with reproduction.");
1758
+ }
1759
+ const createMockInstance = options.createMockInstance;
1760
+ const prototypeMembers = currentValue.prototype ? collectFunctionProperties(currentValue.prototype) : [];
1761
+ return createMockInstance({
1762
+ name: currentValue.name,
1763
+ prototypeMembers,
1764
+ originalImplementation: options.type === "autospy" ? currentValue : void 0,
1765
+ keepMembersImplementation: options.type === "autospy"
1766
+ });
1767
+ };
2040
1768
  const mockPropertiesOf = (container, newContainer) => {
2041
1769
  const containerType = getType(container);
2042
1770
  const isModule = containerType === "Module" || !!container.__esModule;
2043
1771
  for (const { key: property, descriptor } of getAllMockableProperties(container, isModule, options.globalConstructors)) {
2044
1772
  if (!isModule && descriptor.get) {
2045
1773
  try {
2046
- Object.defineProperty(newContainer, property, descriptor);
1774
+ if (options.type === "autospy") {
1775
+ Object.defineProperty(newContainer, property, descriptor);
1776
+ } else {
1777
+ Object.defineProperty(newContainer, property, {
1778
+ configurable: descriptor.configurable,
1779
+ enumerable: descriptor.enumerable,
1780
+ get: () => {
1781
+ },
1782
+ set: descriptor.set ? () => {
1783
+ } : void 0
1784
+ });
1785
+ }
2047
1786
  } catch {
2048
1787
  }
2049
1788
  continue;
2050
1789
  }
2051
- if (isSpecialProp(property, containerType)) {
1790
+ if (isReadonlyProp(container[property], property)) {
2052
1791
  continue;
2053
1792
  }
2054
1793
  const value = container[property];
@@ -2059,7 +1798,22 @@ function mockObject(options, object2, mockExports = {}) {
2059
1798
  }
2060
1799
  const type = getType(value);
2061
1800
  if (Array.isArray(value)) {
2062
- define(newContainer, property, []);
1801
+ if (options.type === "automock") {
1802
+ define(newContainer, property, []);
1803
+ } else {
1804
+ const array = value.map((value2) => {
1805
+ if (value2 && typeof value2 === "object") {
1806
+ const newObject = {};
1807
+ mockPropertiesOf(value2, newObject);
1808
+ return newObject;
1809
+ }
1810
+ if (typeof value2 === "function") {
1811
+ return createMock(value2);
1812
+ }
1813
+ return value2;
1814
+ });
1815
+ define(newContainer, property, array);
1816
+ }
2063
1817
  continue;
2064
1818
  }
2065
1819
  const isFunction = type.includes("Function") && typeof value === "function";
@@ -2067,47 +1821,12 @@ function mockObject(options, object2, mockExports = {}) {
2067
1821
  define(newContainer, property, value);
2068
1822
  continue;
2069
1823
  }
2070
- if (!define(newContainer, property, isFunction ? value : {})) {
1824
+ if (!define(newContainer, property, isFunction || options.type === "autospy" ? value : {})) {
2071
1825
  continue;
2072
1826
  }
2073
1827
  if (isFunction) {
2074
- let mockFunction = function() {
2075
- if (this instanceof newContainer[property]) {
2076
- for (const { key, descriptor: descriptor2 } of getAllMockableProperties(this, false, options.globalConstructors)) {
2077
- if (descriptor2.get) {
2078
- continue;
2079
- }
2080
- const value2 = this[key];
2081
- const type2 = getType(value2);
2082
- const isFunction2 = type2.includes("Function") && typeof value2 === "function";
2083
- if (isFunction2) {
2084
- const original = this[key];
2085
- const mock2 = spyOn(this, key).mockImplementation(original);
2086
- const origMockReset = mock2.mockReset;
2087
- mock2.mockRestore = mock2.mockReset = () => {
2088
- origMockReset.call(mock2);
2089
- mock2.mockImplementation(original);
2090
- return mock2;
2091
- };
2092
- }
2093
- }
2094
- }
2095
- };
2096
- if (!options.spyOn) {
2097
- throw new Error("[@vitest/mocker] `spyOn` is not defined. This is a Vitest error. Please open a new issue with reproduction.");
2098
- }
2099
- const spyOn = options.spyOn;
2100
- const mock = spyOn(newContainer, property);
2101
- if (options.type === "automock") {
2102
- mock.mockImplementation(mockFunction);
2103
- const origMockReset = mock.mockReset;
2104
- mock.mockRestore = mock.mockReset = () => {
2105
- origMockReset.call(mock);
2106
- mock.mockImplementation(mockFunction);
2107
- return mock;
2108
- };
2109
- }
2110
- Object.defineProperty(newContainer[property], "length", { value: 0 });
1828
+ const mock = createMock(newContainer[property]);
1829
+ newContainer[property] = mock;
2111
1830
  }
2112
1831
  refs.track(value, newContainer[property]);
2113
1832
  mockPropertiesOf(value, newContainer[property]);
@@ -2141,14 +1860,15 @@ class RefTracker {
2141
1860
  function getType(value) {
2142
1861
  return Object.prototype.toString.apply(value).slice(8, -1);
2143
1862
  }
2144
- function isSpecialProp(prop, parentType) {
2145
- return parentType.includes("Function") && typeof prop === "string" && [
2146
- "arguments",
2147
- "callee",
2148
- "caller",
2149
- "length",
2150
- "name"
2151
- ].includes(prop);
1863
+ function isReadonlyProp(object2, prop) {
1864
+ if (prop === "arguments" || prop === "caller" || prop === "callee" || prop === "name" || prop === "length") {
1865
+ const typeName = getType(object2);
1866
+ return typeName === "Function" || typeName === "AsyncFunction" || typeName === "GeneratorFunction" || typeName === "AsyncGeneratorFunction";
1867
+ }
1868
+ if (prop === "source" || prop === "global" || prop === "ignoreCase" || prop === "multiline") {
1869
+ return getType(object2) === "RegExp";
1870
+ }
1871
+ return false;
2152
1872
  }
2153
1873
  function getAllMockableProperties(obj, isModule, constructors) {
2154
1874
  const { Map: Map2, Object: Object2, Function: Function2, RegExp: RegExp2, Array: Array2 } = constructors;
@@ -2184,6 +1904,20 @@ function collectOwnProperties(obj, collector) {
2184
1904
  Object.getOwnPropertyNames(obj).forEach(collect);
2185
1905
  Object.getOwnPropertySymbols(obj).forEach(collect);
2186
1906
  }
1907
+ function collectFunctionProperties(prototype) {
1908
+ const properties = /* @__PURE__ */ new Set();
1909
+ collectOwnProperties(prototype, (prop) => {
1910
+ const descriptor = Object.getOwnPropertyDescriptor(prototype, prop);
1911
+ if (!descriptor || descriptor.get) {
1912
+ return;
1913
+ }
1914
+ const type = getType(descriptor.value);
1915
+ if (type.includes("Function") && !isReadonlyProp(descriptor.value, prop)) {
1916
+ properties.add(prop);
1917
+ }
1918
+ });
1919
+ return Array.from(properties);
1920
+ }
2187
1921
  const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
2188
1922
  function normalizeWindowsPath(input = "") {
2189
1923
  if (!input) {
@@ -2666,20 +2400,6 @@ const reactIsMethods = [
2666
2400
  "isValidElementType"
2667
2401
  ];
2668
2402
  Object.fromEntries(reactIsMethods.map((m) => [m, (v) => ReactIs18[m](v) || ReactIs19[m](v)]));
2669
- let getPromiseValue = () => "Promise{…}";
2670
- try {
2671
- const { getPromiseDetails, kPending, kRejected } = process.binding("util");
2672
- if (Array.isArray(getPromiseDetails(Promise.resolve()))) {
2673
- getPromiseValue = (value, options) => {
2674
- const [state, innerValue] = getPromiseDetails(value);
2675
- if (state === kPending) {
2676
- return "Promise{<pending>}";
2677
- }
2678
- return `Promise${state === kRejected ? "!" : ""}{${options.inspect(innerValue, options)}}`;
2679
- };
2680
- }
2681
- } catch (notNode) {
2682
- }
2683
2403
  var jsTokens_1;
2684
2404
  var hasRequiredJsTokens;
2685
2405
  function requireJsTokens() {
@@ -3144,13 +2864,13 @@ var UrlType;
3144
2864
  })(UrlType || (UrlType = {}));
3145
2865
  const { now } = Date;
3146
2866
  class ModuleMocker {
3147
- constructor(interceptor, rpc2, spyOn, config) {
2867
+ constructor(interceptor, rpc2, createMockInstance, config) {
3148
2868
  __publicField(this, "registry", new MockerRegistry());
3149
2869
  __publicField(this, "queue", /* @__PURE__ */ new Set());
3150
2870
  __publicField(this, "mockedIds", /* @__PURE__ */ new Set());
3151
2871
  this.interceptor = interceptor;
3152
2872
  this.rpc = rpc2;
3153
- this.spyOn = spyOn;
2873
+ this.createMockInstance = createMockInstance;
3154
2874
  this.config = config;
3155
2875
  }
3156
2876
  async prepare() {
@@ -3248,7 +2968,7 @@ class ModuleMocker {
3248
2968
  Map,
3249
2969
  RegExp
3250
2970
  },
3251
- spyOn: this.spyOn,
2971
+ createMockInstance: this.createMockInstance,
3252
2972
  type: moduleType
3253
2973
  }, object2);
3254
2974
  }
@@ -3375,6 +3095,7 @@ class CommandsManager {
3375
3095
  });
3376
3096
  }
3377
3097
  }
3098
+ const __vite_import_meta_env__ = { "BASE_URL": "/", "DEV": false, "MODE": "production", "PROD": true, "SSR": false, "VITE_TEST_WATCHER_DEBUG": "false" };
3378
3099
  const debugVar = getConfig().env.VITEST_BROWSER_DEBUG;
3379
3100
  const debug = debugVar && debugVar !== "false" ? (...args) => {
3380
3101
  var _a, _b;
@@ -3386,7 +3107,7 @@ channel.addEventListener("message", async (e) => {
3386
3107
  debug == null ? void 0 : debug("event from orchestrator", JSON.stringify(e.data));
3387
3108
  if (!isEvent(data)) {
3388
3109
  const error = new Error(`Unknown message: ${JSON.stringify(e.data)}`);
3389
- unhandledError(error, "Uknown Iframe Message");
3110
+ unhandledError(error, "Unknown Iframe Message");
3390
3111
  return;
3391
3112
  }
3392
3113
  if (!("iframeId" in data) || data.iframeId !== getBrowserState().iframeId) {
@@ -3396,7 +3117,7 @@ channel.addEventListener("message", async (e) => {
3396
3117
  case "execute": {
3397
3118
  const { method, files, context } = data;
3398
3119
  const state = getWorkerState();
3399
- const parsedContext = parse(context);
3120
+ const parsedContext = parse$1(context);
3400
3121
  state.ctx.providedContext = parsedContext;
3401
3122
  state.providedContext = parsedContext;
3402
3123
  if (method === "collect") {
@@ -3421,7 +3142,7 @@ channel.addEventListener("message", async (e) => {
3421
3142
  }
3422
3143
  default: {
3423
3144
  const error = new Error(`Unknown event: ${data.event}`);
3424
- unhandledError(error, "Uknown Event");
3145
+ unhandledError(error, "Unknown Event");
3425
3146
  }
3426
3147
  }
3427
3148
  channel.postMessage({
@@ -3430,24 +3151,24 @@ channel.addEventListener("message", async (e) => {
3430
3151
  });
3431
3152
  });
3432
3153
  const url = new URL(location.href);
3433
- const reloadStart = url.searchParams.get("__reloadStart");
3434
3154
  const iframeId = url.searchParams.get("iframeId");
3435
3155
  const commands = new CommandsManager();
3436
3156
  getBrowserState().commands = commands;
3437
3157
  getBrowserState().iframeId = iframeId;
3438
3158
  let contextSwitched = false;
3439
3159
  async function prepareTestEnvironment(options) {
3440
- debug == null ? void 0 : debug("trying to resolve runner", `${reloadStart}`);
3160
+ debug == null ? void 0 : debug("trying to resolve the runner");
3441
3161
  const config = getConfig();
3442
3162
  const rpc2 = createSafeRpc(client);
3443
3163
  const state = getWorkerState();
3164
+ state.metaEnv = __vite_import_meta_env__;
3444
3165
  state.onCancel = onCancel;
3445
3166
  state.rpc = rpc2;
3446
3167
  const interceptor = createModuleMockerInterceptor();
3447
3168
  const mocker = new VitestBrowserClientMocker(
3448
3169
  interceptor,
3449
3170
  rpc2,
3450
- SpyModule.spyOn,
3171
+ SpyModule.createMockInstance,
3451
3172
  {
3452
3173
  root: getBrowserState().viteConfig.root
3453
3174
  }
@@ -3513,7 +3234,7 @@ async function prepare(options) {
3513
3234
  debug == null ? void 0 : debug("prepare time", state.durations.prepare, "ms");
3514
3235
  await Promise.all([
3515
3236
  setupCommonEnv(config),
3516
- startCoverageInsideWorker(config.coverage, executor, { isolate: config.browser.isolate }),
3237
+ startCoverageInsideWorker(config.coverage, moduleRunner, { isolate: config.browser.isolate }),
3517
3238
  (async () => {
3518
3239
  const VitestIndex = await __vitePreload(() => import("vitest"), true ? [] : void 0);
3519
3240
  Object.defineProperty(window, "__vitest_index__", {
@@ -3522,6 +3243,9 @@ async function prepare(options) {
3522
3243
  });
3523
3244
  })()
3524
3245
  ]);
3246
+ if (!config.browser.trackUnhandledErrors) {
3247
+ getBrowserState().disposeExceptionTracker();
3248
+ }
3525
3249
  }
3526
3250
  async function cleanup() {
3527
3251
  const state = getWorkerState();
@@ -3543,7 +3267,7 @@ async function cleanup() {
3543
3267
  await rpc2.wdioSwitchContext("parent").catch((error) => unhandledError(error, "Cleanup Error"));
3544
3268
  }
3545
3269
  state.environmentTeardownRun = true;
3546
- await stopCoverageInsideWorker(config.coverage, executor, { isolate: config.browser.isolate }).catch((error) => {
3270
+ await stopCoverageInsideWorker(config.coverage, moduleRunner, { isolate: config.browser.isolate }).catch((error) => {
3547
3271
  return unhandledError(error, "Coverage Error");
3548
3272
  });
3549
3273
  }