@vitest/browser 3.2.4 → 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.
- package/LICENSE +1 -1
- package/README.md +3 -15
- package/context.d.ts +153 -3
- package/dist/client/.vite/manifest.json +6 -6
- package/dist/client/__vitest__/assets/index-DFDJV2DF.js +53 -0
- package/dist/client/__vitest__/assets/{index-X8b7Z_4p.css → index-KbpJLW--.css} +1 -1
- package/dist/client/__vitest__/index.html +2 -2
- package/dist/client/__vitest_browser__/orchestrator-BXX6oamz.js +296 -0
- package/dist/client/__vitest_browser__/{tester-BYDMHqQ9.js → tester-CMhJ1E1W.js} +301 -580
- package/dist/client/__vitest_browser__/{utils-Owv5OOOf.js → utils-CPmDBIKG.js} +3 -3
- package/dist/client/error-catcher.js +7 -3
- package/dist/client/esm-client-injector.js +1 -0
- package/dist/client/orchestrator.html +2 -2
- package/dist/client/tester/tester.html +2 -2
- package/dist/client.js +24 -8
- package/dist/context.js +34 -24
- package/dist/expect-element.js +10 -8
- package/dist/index-CwoiDq7G.js +6 -0
- package/dist/index-DDlvjJVO.js +1 -0
- package/dist/index.d.ts +20 -15
- package/dist/index.js +550 -98
- package/dist/locators/index.d.ts +8 -7
- package/dist/locators/index.js +1 -1
- package/dist/locators/playwright.js +1 -1
- package/dist/locators/preview.js +1 -1
- package/dist/locators/webdriverio.js +1 -1
- package/dist/providers/playwright.d.ts +103 -0
- package/dist/{webdriver-KA1WiV0q.js → providers/playwright.js} +37 -180
- package/dist/providers/preview.d.ts +16 -0
- package/dist/{providers.js → providers/preview.js} +17 -21
- package/dist/providers/webdriverio.d.ts +50 -0
- package/dist/providers/webdriverio.js +171 -0
- package/dist/shared/screenshotMatcher/types.d.ts +16 -0
- package/dist/state.js +5 -2
- package/dist/types.d.ts +69 -0
- package/jest-dom.d.ts +95 -1
- package/package.json +22 -30
- package/utils.d.ts +1 -1
- package/dist/client/__vitest__/assets/index-D_ryMEPs.js +0 -58
- package/dist/client/__vitest_browser__/orchestrator-Bo1OwGWc.js +0 -3213
- package/dist/index-W1MM53zC.js +0 -1
- package/providers/playwright.d.ts +0 -81
- 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,
|
|
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;
|
|
@@ -141,23 +141,17 @@ function setupDialogsSpy() {
|
|
|
141
141
|
}
|
|
142
142
|
const { get } = Reflect;
|
|
143
143
|
function withSafeTimers(getTimers, fn) {
|
|
144
|
-
const { setTimeout, clearTimeout
|
|
144
|
+
const { setTimeout, clearTimeout } = getTimers();
|
|
145
145
|
const currentSetTimeout = globalThis.setTimeout;
|
|
146
146
|
const currentClearTimeout = globalThis.clearTimeout;
|
|
147
|
-
const currentSetImmediate = globalThis.setImmediate;
|
|
148
|
-
const currentClearImmediate = globalThis.clearImmediate;
|
|
149
147
|
try {
|
|
150
148
|
globalThis.setTimeout = setTimeout;
|
|
151
149
|
globalThis.clearTimeout = clearTimeout;
|
|
152
|
-
globalThis.setImmediate = setImmediate;
|
|
153
|
-
globalThis.clearImmediate = clearImmediate;
|
|
154
150
|
const result = fn();
|
|
155
151
|
return result;
|
|
156
152
|
} finally {
|
|
157
153
|
globalThis.setTimeout = currentSetTimeout;
|
|
158
154
|
globalThis.clearTimeout = currentClearTimeout;
|
|
159
|
-
globalThis.setImmediate = currentSetImmediate;
|
|
160
|
-
globalThis.clearImmediate = currentClearImmediate;
|
|
161
155
|
}
|
|
162
156
|
}
|
|
163
157
|
const promises = /* @__PURE__ */ new Set();
|
|
@@ -185,7 +179,9 @@ function createSafeRpc(client2) {
|
|
|
185
179
|
function rpc$2() {
|
|
186
180
|
return globalThis.__vitest_worker__.rpc;
|
|
187
181
|
}
|
|
188
|
-
|
|
182
|
+
function getDefaultExportFromCjs$1(x) {
|
|
183
|
+
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
184
|
+
}
|
|
189
185
|
var sourcemapCodec_umd$1 = { exports: {} };
|
|
190
186
|
var sourcemapCodec_umd = sourcemapCodec_umd$1.exports;
|
|
191
187
|
var hasRequiredSourcemapCodec_umd;
|
|
@@ -567,9 +563,9 @@ function requireSourcemapCodec_umd() {
|
|
|
567
563
|
return decoded;
|
|
568
564
|
}
|
|
569
565
|
function sort(line) {
|
|
570
|
-
line.sort(
|
|
566
|
+
line.sort(sortComparator2);
|
|
571
567
|
}
|
|
572
|
-
function
|
|
568
|
+
function sortComparator2(a2, b) {
|
|
573
569
|
return a2[0] - b[0];
|
|
574
570
|
}
|
|
575
571
|
function encode(decoded) {
|
|
@@ -613,6 +609,7 @@ function requireSourcemapCodec_umd() {
|
|
|
613
609
|
})(sourcemapCodec_umd$1, sourcemapCodec_umd$1.exports);
|
|
614
610
|
return sourcemapCodec_umd$1.exports;
|
|
615
611
|
}
|
|
612
|
+
var sourcemapCodec_umdExports = requireSourcemapCodec_umd();
|
|
616
613
|
var resolveUri_umd$1 = { exports: {} };
|
|
617
614
|
var resolveUri_umd = resolveUri_umd$1.exports;
|
|
618
615
|
var hasRequiredResolveUri_umd;
|
|
@@ -805,485 +802,192 @@ function requireResolveUri_umd() {
|
|
|
805
802
|
})(resolveUri_umd$1);
|
|
806
803
|
return resolveUri_umd$1.exports;
|
|
807
804
|
}
|
|
808
|
-
var
|
|
809
|
-
|
|
810
|
-
function
|
|
811
|
-
if (
|
|
812
|
-
|
|
813
|
-
(
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
} else if (sl < stopLine) {
|
|
994
|
-
sc = columnOffset + nextOffset.column;
|
|
995
|
-
}
|
|
996
|
-
}
|
|
997
|
-
addSection(map, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset + offset.line, columnOffset + offset.column, sl, sc);
|
|
998
|
-
}
|
|
999
|
-
}
|
|
1000
|
-
function addSection(input, mapUrl, mappings, sources, sourcesContent, names, ignoreList, lineOffset, columnOffset, stopLine, stopColumn) {
|
|
1001
|
-
const parsed = parse2(input);
|
|
1002
|
-
if ("sections" in parsed)
|
|
1003
|
-
return recurse(...arguments);
|
|
1004
|
-
const map = new TraceMap2(parsed, mapUrl);
|
|
1005
|
-
const sourcesOffset = sources.length;
|
|
1006
|
-
const namesOffset = names.length;
|
|
1007
|
-
const decoded = decodedMappings(map);
|
|
1008
|
-
const { resolvedSources, sourcesContent: contents, ignoreList: ignores } = map;
|
|
1009
|
-
append(sources, resolvedSources);
|
|
1010
|
-
append(names, map.names);
|
|
1011
|
-
if (contents)
|
|
1012
|
-
append(sourcesContent, contents);
|
|
1013
|
-
else
|
|
1014
|
-
for (let i = 0; i < resolvedSources.length; i++)
|
|
1015
|
-
sourcesContent.push(null);
|
|
1016
|
-
if (ignores)
|
|
1017
|
-
for (let i = 0; i < ignores.length; i++)
|
|
1018
|
-
ignoreList.push(ignores[i] + sourcesOffset);
|
|
1019
|
-
for (let i = 0; i < decoded.length; i++) {
|
|
1020
|
-
const lineI = lineOffset + i;
|
|
1021
|
-
if (lineI > stopLine)
|
|
1022
|
-
return;
|
|
1023
|
-
const out = getLine(mappings, lineI);
|
|
1024
|
-
const cOffset = i === 0 ? columnOffset : 0;
|
|
1025
|
-
const line = decoded[i];
|
|
1026
|
-
for (let j = 0; j < line.length; j++) {
|
|
1027
|
-
const seg = line[j];
|
|
1028
|
-
const column = cOffset + seg[COLUMN];
|
|
1029
|
-
if (lineI === stopLine && column >= stopColumn)
|
|
1030
|
-
return;
|
|
1031
|
-
if (seg.length === 1) {
|
|
1032
|
-
out.push([column]);
|
|
1033
|
-
continue;
|
|
1034
|
-
}
|
|
1035
|
-
const sourcesIndex = sourcesOffset + seg[SOURCES_INDEX];
|
|
1036
|
-
const sourceLine = seg[SOURCE_LINE];
|
|
1037
|
-
const sourceColumn = seg[SOURCE_COLUMN];
|
|
1038
|
-
out.push(seg.length === 4 ? [column, sourcesIndex, sourceLine, sourceColumn] : [column, sourcesIndex, sourceLine, sourceColumn, namesOffset + seg[NAMES_INDEX]]);
|
|
1039
|
-
}
|
|
1040
|
-
}
|
|
1041
|
-
}
|
|
1042
|
-
function append(arr, other) {
|
|
1043
|
-
for (let i = 0; i < other.length; i++)
|
|
1044
|
-
arr.push(other[i]);
|
|
1045
|
-
}
|
|
1046
|
-
function getLine(arr, index2) {
|
|
1047
|
-
for (let i = arr.length; i <= index2; i++)
|
|
1048
|
-
arr[i] = [];
|
|
1049
|
-
return arr[index2];
|
|
1050
|
-
}
|
|
1051
|
-
const LINE_GTR_ZERO = "`line` must be greater than 0 (lines start at line 1)";
|
|
1052
|
-
const COL_GTR_EQ_ZERO = "`column` must be greater than or equal to 0 (columns start at column 0)";
|
|
1053
|
-
const LEAST_UPPER_BOUND = -1;
|
|
1054
|
-
const GREATEST_LOWER_BOUND = 1;
|
|
1055
|
-
class TraceMap2 {
|
|
1056
|
-
constructor(map, mapUrl) {
|
|
1057
|
-
const isString = typeof map === "string";
|
|
1058
|
-
if (!isString && map._decodedMemo)
|
|
1059
|
-
return map;
|
|
1060
|
-
const parsed = isString ? JSON.parse(map) : map;
|
|
1061
|
-
const { version, file, names, sourceRoot, sources, sourcesContent } = parsed;
|
|
1062
|
-
this.version = version;
|
|
1063
|
-
this.file = file;
|
|
1064
|
-
this.names = names || [];
|
|
1065
|
-
this.sourceRoot = sourceRoot;
|
|
1066
|
-
this.sources = sources;
|
|
1067
|
-
this.sourcesContent = sourcesContent;
|
|
1068
|
-
this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0;
|
|
1069
|
-
const from = resolve2(sourceRoot || "", stripFilename(mapUrl));
|
|
1070
|
-
this.resolvedSources = sources.map((s) => resolve2(s || "", from));
|
|
1071
|
-
const { mappings } = parsed;
|
|
1072
|
-
if (typeof mappings === "string") {
|
|
1073
|
-
this._encoded = mappings;
|
|
1074
|
-
this._decoded = void 0;
|
|
1075
|
-
} else {
|
|
1076
|
-
this._encoded = void 0;
|
|
1077
|
-
this._decoded = maybeSort(mappings, isString);
|
|
1078
|
-
}
|
|
1079
|
-
this._decodedMemo = memoizedState();
|
|
1080
|
-
this._bySources = void 0;
|
|
1081
|
-
this._bySourceMemos = void 0;
|
|
1082
|
-
}
|
|
1083
|
-
}
|
|
1084
|
-
function cast(map) {
|
|
1085
|
-
return map;
|
|
1086
|
-
}
|
|
1087
|
-
function encodedMappings(map) {
|
|
1088
|
-
var _a;
|
|
1089
|
-
var _b;
|
|
1090
|
-
return (_a = (_b = cast(map))._encoded) !== null && _a !== void 0 ? _a : _b._encoded = sourcemapCodec.encode(cast(map)._decoded);
|
|
1091
|
-
}
|
|
1092
|
-
function decodedMappings(map) {
|
|
1093
|
-
var _a;
|
|
1094
|
-
return (_a = cast(map))._decoded || (_a._decoded = sourcemapCodec.decode(cast(map)._encoded));
|
|
1095
|
-
}
|
|
1096
|
-
function traceSegment(map, line, column) {
|
|
1097
|
-
const decoded = decodedMappings(map);
|
|
1098
|
-
if (line >= decoded.length)
|
|
1099
|
-
return null;
|
|
1100
|
-
const segments = decoded[line];
|
|
1101
|
-
const index2 = traceSegmentInternal(segments, cast(map)._decodedMemo, line, column, GREATEST_LOWER_BOUND);
|
|
1102
|
-
return index2 === -1 ? null : segments[index2];
|
|
1103
|
-
}
|
|
1104
|
-
function originalPositionFor2(map, needle) {
|
|
1105
|
-
let { line, column, bias } = needle;
|
|
1106
|
-
line--;
|
|
1107
|
-
if (line < 0)
|
|
1108
|
-
throw new Error(LINE_GTR_ZERO);
|
|
1109
|
-
if (column < 0)
|
|
1110
|
-
throw new Error(COL_GTR_EQ_ZERO);
|
|
1111
|
-
const decoded = decodedMappings(map);
|
|
1112
|
-
if (line >= decoded.length)
|
|
1113
|
-
return OMapping(null, null, null, null);
|
|
1114
|
-
const segments = decoded[line];
|
|
1115
|
-
const index2 = traceSegmentInternal(segments, cast(map)._decodedMemo, line, column, bias || GREATEST_LOWER_BOUND);
|
|
1116
|
-
if (index2 === -1)
|
|
1117
|
-
return OMapping(null, null, null, null);
|
|
1118
|
-
const segment = segments[index2];
|
|
1119
|
-
if (segment.length === 1)
|
|
1120
|
-
return OMapping(null, null, null, null);
|
|
1121
|
-
const { names, resolvedSources } = map;
|
|
1122
|
-
return OMapping(resolvedSources[segment[SOURCES_INDEX]], segment[SOURCE_LINE] + 1, segment[SOURCE_COLUMN], segment.length === 5 ? names[segment[NAMES_INDEX]] : null);
|
|
1123
|
-
}
|
|
1124
|
-
function generatedPositionFor(map, needle) {
|
|
1125
|
-
const { source, line, column, bias } = needle;
|
|
1126
|
-
return generatedPosition(map, source, line, column, bias || GREATEST_LOWER_BOUND, false);
|
|
1127
|
-
}
|
|
1128
|
-
function allGeneratedPositionsFor(map, needle) {
|
|
1129
|
-
const { source, line, column, bias } = needle;
|
|
1130
|
-
return generatedPosition(map, source, line, column, bias || LEAST_UPPER_BOUND, true);
|
|
1131
|
-
}
|
|
1132
|
-
function eachMapping(map, cb) {
|
|
1133
|
-
const decoded = decodedMappings(map);
|
|
1134
|
-
const { names, resolvedSources } = map;
|
|
1135
|
-
for (let i = 0; i < decoded.length; i++) {
|
|
1136
|
-
const line = decoded[i];
|
|
1137
|
-
for (let j = 0; j < line.length; j++) {
|
|
1138
|
-
const seg = line[j];
|
|
1139
|
-
const generatedLine = i + 1;
|
|
1140
|
-
const generatedColumn = seg[0];
|
|
1141
|
-
let source = null;
|
|
1142
|
-
let originalLine = null;
|
|
1143
|
-
let originalColumn = null;
|
|
1144
|
-
let name = null;
|
|
1145
|
-
if (seg.length !== 1) {
|
|
1146
|
-
source = resolvedSources[seg[1]];
|
|
1147
|
-
originalLine = seg[2] + 1;
|
|
1148
|
-
originalColumn = seg[3];
|
|
1149
|
-
}
|
|
1150
|
-
if (seg.length === 5)
|
|
1151
|
-
name = names[seg[4]];
|
|
1152
|
-
cb({
|
|
1153
|
-
generatedLine,
|
|
1154
|
-
generatedColumn,
|
|
1155
|
-
source,
|
|
1156
|
-
originalLine,
|
|
1157
|
-
originalColumn,
|
|
1158
|
-
name
|
|
1159
|
-
});
|
|
1160
|
-
}
|
|
1161
|
-
}
|
|
1162
|
-
}
|
|
1163
|
-
function sourceIndex(map, source) {
|
|
1164
|
-
const { sources, resolvedSources } = map;
|
|
1165
|
-
let index2 = sources.indexOf(source);
|
|
1166
|
-
if (index2 === -1)
|
|
1167
|
-
index2 = resolvedSources.indexOf(source);
|
|
1168
|
-
return index2;
|
|
1169
|
-
}
|
|
1170
|
-
function sourceContentFor(map, source) {
|
|
1171
|
-
const { sourcesContent } = map;
|
|
1172
|
-
if (sourcesContent == null)
|
|
1173
|
-
return null;
|
|
1174
|
-
const index2 = sourceIndex(map, source);
|
|
1175
|
-
return index2 === -1 ? null : sourcesContent[index2];
|
|
1176
|
-
}
|
|
1177
|
-
function isIgnored(map, source) {
|
|
1178
|
-
const { ignoreList } = map;
|
|
1179
|
-
if (ignoreList == null)
|
|
1180
|
-
return false;
|
|
1181
|
-
const index2 = sourceIndex(map, source);
|
|
1182
|
-
return index2 === -1 ? false : ignoreList.includes(index2);
|
|
1183
|
-
}
|
|
1184
|
-
function presortedDecodedMap(map, mapUrl) {
|
|
1185
|
-
const tracer = new TraceMap2(clone(map, []), mapUrl);
|
|
1186
|
-
cast(tracer)._decoded = map.mappings;
|
|
1187
|
-
return tracer;
|
|
1188
|
-
}
|
|
1189
|
-
function decodedMap(map) {
|
|
1190
|
-
return clone(map, decodedMappings(map));
|
|
1191
|
-
}
|
|
1192
|
-
function encodedMap(map) {
|
|
1193
|
-
return clone(map, encodedMappings(map));
|
|
1194
|
-
}
|
|
1195
|
-
function clone(map, mappings) {
|
|
1196
|
-
return {
|
|
1197
|
-
version: map.version,
|
|
1198
|
-
file: map.file,
|
|
1199
|
-
names: map.names,
|
|
1200
|
-
sourceRoot: map.sourceRoot,
|
|
1201
|
-
sources: map.sources,
|
|
1202
|
-
sourcesContent: map.sourcesContent,
|
|
1203
|
-
mappings,
|
|
1204
|
-
ignoreList: map.ignoreList || map.x_google_ignoreList
|
|
1205
|
-
};
|
|
1206
|
-
}
|
|
1207
|
-
function OMapping(source, line, column, name) {
|
|
1208
|
-
return { source, line, column, name };
|
|
1209
|
-
}
|
|
1210
|
-
function GMapping(line, column) {
|
|
1211
|
-
return { line, column };
|
|
1212
|
-
}
|
|
1213
|
-
function traceSegmentInternal(segments, memo, line, column, bias) {
|
|
1214
|
-
let index2 = memoizedBinarySearch(segments, column, memo, line);
|
|
1215
|
-
if (found) {
|
|
1216
|
-
index2 = (bias === LEAST_UPPER_BOUND ? upperBound : lowerBound)(segments, column, index2);
|
|
1217
|
-
} else if (bias === LEAST_UPPER_BOUND)
|
|
1218
|
-
index2++;
|
|
1219
|
-
if (index2 === -1 || index2 === segments.length)
|
|
1220
|
-
return -1;
|
|
1221
|
-
return index2;
|
|
1222
|
-
}
|
|
1223
|
-
function sliceGeneratedPositions(segments, memo, line, column, bias) {
|
|
1224
|
-
let min = traceSegmentInternal(segments, memo, line, column, GREATEST_LOWER_BOUND);
|
|
1225
|
-
if (!found && bias === LEAST_UPPER_BOUND)
|
|
1226
|
-
min++;
|
|
1227
|
-
if (min === -1 || min === segments.length)
|
|
1228
|
-
return [];
|
|
1229
|
-
const matchedColumn = found ? column : segments[min][COLUMN];
|
|
1230
|
-
if (!found)
|
|
1231
|
-
min = lowerBound(segments, matchedColumn, min);
|
|
1232
|
-
const max = upperBound(segments, matchedColumn, min);
|
|
1233
|
-
const result = [];
|
|
1234
|
-
for (; min <= max; min++) {
|
|
1235
|
-
const segment = segments[min];
|
|
1236
|
-
result.push(GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]));
|
|
1237
|
-
}
|
|
1238
|
-
return result;
|
|
1239
|
-
}
|
|
1240
|
-
function generatedPosition(map, source, line, column, bias, all) {
|
|
1241
|
-
var _a;
|
|
1242
|
-
line--;
|
|
1243
|
-
if (line < 0)
|
|
1244
|
-
throw new Error(LINE_GTR_ZERO);
|
|
1245
|
-
if (column < 0)
|
|
1246
|
-
throw new Error(COL_GTR_EQ_ZERO);
|
|
1247
|
-
const { sources, resolvedSources } = map;
|
|
1248
|
-
let sourceIndex2 = sources.indexOf(source);
|
|
1249
|
-
if (sourceIndex2 === -1)
|
|
1250
|
-
sourceIndex2 = resolvedSources.indexOf(source);
|
|
1251
|
-
if (sourceIndex2 === -1)
|
|
1252
|
-
return all ? [] : GMapping(null, null);
|
|
1253
|
-
const generated = (_a = cast(map))._bySources || (_a._bySources = buildBySources(decodedMappings(map), cast(map)._bySourceMemos = sources.map(memoizedState)));
|
|
1254
|
-
const segments = generated[sourceIndex2][line];
|
|
1255
|
-
if (segments == null)
|
|
1256
|
-
return all ? [] : GMapping(null, null);
|
|
1257
|
-
const memo = cast(map)._bySourceMemos[sourceIndex2];
|
|
1258
|
-
if (all)
|
|
1259
|
-
return sliceGeneratedPositions(segments, memo, line, column, bias);
|
|
1260
|
-
const index2 = traceSegmentInternal(segments, memo, line, column, bias);
|
|
1261
|
-
if (index2 === -1)
|
|
1262
|
-
return GMapping(null, null);
|
|
1263
|
-
const segment = segments[index2];
|
|
1264
|
-
return GMapping(segment[REV_GENERATED_LINE] + 1, segment[REV_GENERATED_COLUMN]);
|
|
1265
|
-
}
|
|
1266
|
-
exports2.AnyMap = AnyMap;
|
|
1267
|
-
exports2.GREATEST_LOWER_BOUND = GREATEST_LOWER_BOUND;
|
|
1268
|
-
exports2.LEAST_UPPER_BOUND = LEAST_UPPER_BOUND;
|
|
1269
|
-
exports2.TraceMap = TraceMap2;
|
|
1270
|
-
exports2.allGeneratedPositionsFor = allGeneratedPositionsFor;
|
|
1271
|
-
exports2.decodedMap = decodedMap;
|
|
1272
|
-
exports2.decodedMappings = decodedMappings;
|
|
1273
|
-
exports2.eachMapping = eachMapping;
|
|
1274
|
-
exports2.encodedMap = encodedMap;
|
|
1275
|
-
exports2.encodedMappings = encodedMappings;
|
|
1276
|
-
exports2.generatedPositionFor = generatedPositionFor;
|
|
1277
|
-
exports2.isIgnored = isIgnored;
|
|
1278
|
-
exports2.originalPositionFor = originalPositionFor2;
|
|
1279
|
-
exports2.presortedDecodedMap = presortedDecodedMap;
|
|
1280
|
-
exports2.sourceContentFor = sourceContentFor;
|
|
1281
|
-
exports2.traceSegment = traceSegment;
|
|
1282
|
-
});
|
|
1283
|
-
})(traceMapping_umd$1, traceMapping_umd$1.exports);
|
|
1284
|
-
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;
|
|
1285
990
|
}
|
|
1286
|
-
var traceMapping_umdExports = requireTraceMapping_umd();
|
|
1287
991
|
function notNullish(v) {
|
|
1288
992
|
return v != null;
|
|
1289
993
|
}
|
|
@@ -1300,6 +1004,8 @@ const stackIgnorePatterns = [
|
|
|
1300
1004
|
"/node_modules/chai/",
|
|
1301
1005
|
"/node_modules/tinypool/",
|
|
1302
1006
|
"/node_modules/tinyspy/",
|
|
1007
|
+
"/vite/dist/node/module-runner",
|
|
1008
|
+
"/rolldown-vite/dist/node/module-runner",
|
|
1303
1009
|
// browser related deps
|
|
1304
1010
|
"/deps/chunk-",
|
|
1305
1011
|
"/deps/@vitest",
|
|
@@ -1422,8 +1128,8 @@ function parseStacktrace(stack, options = {}) {
|
|
|
1422
1128
|
if (!map || typeof map !== "object" || !map.version) {
|
|
1423
1129
|
return shouldFilter(ignoreStackEntries, stack2.file) ? null : stack2;
|
|
1424
1130
|
}
|
|
1425
|
-
const traceMap = new
|
|
1426
|
-
const { line, column, source, name } =
|
|
1131
|
+
const traceMap = new TraceMap(map);
|
|
1132
|
+
const { line, column, source, name } = originalPositionFor(traceMap, stack2);
|
|
1427
1133
|
let file = stack2.file;
|
|
1428
1134
|
if (source) {
|
|
1429
1135
|
const fileUrl = stack2.file.startsWith("file://") ? stack2.file : `file://${stack2.file}`;
|
|
@@ -1492,10 +1198,10 @@ class VitestBrowserSnapshotEnvironment {
|
|
|
1492
1198
|
}
|
|
1493
1199
|
let traceMap = this.traceMaps.get(stack.file);
|
|
1494
1200
|
if (!traceMap) {
|
|
1495
|
-
traceMap = new TraceMap(map);
|
|
1201
|
+
traceMap = new TraceMap$1(map);
|
|
1496
1202
|
this.traceMaps.set(stack.file, traceMap);
|
|
1497
1203
|
}
|
|
1498
|
-
const { line, column } = originalPositionFor(traceMap, stack);
|
|
1204
|
+
const { line, column } = originalPositionFor$1(traceMap, stack);
|
|
1499
1205
|
if (line != null && column != null) {
|
|
1500
1206
|
return { ...stack, line, column };
|
|
1501
1207
|
}
|
|
@@ -1534,9 +1240,12 @@ function createBrowserRunner(runnerClass, mocker, state, coverageModule) {
|
|
|
1534
1240
|
__publicField(this, "onTaskFinished", async (task) => {
|
|
1535
1241
|
var _a, _b;
|
|
1536
1242
|
if (this.config.browser.screenshotFailures && document.body.clientHeight > 0 && ((_a = task.result) == null ? void 0 : _a.state) === "fail") {
|
|
1537
|
-
const screenshot = await page.screenshot(
|
|
1538
|
-
|
|
1539
|
-
|
|
1243
|
+
const screenshot = await page.screenshot(
|
|
1244
|
+
{
|
|
1245
|
+
timeout: ((_b = this.config.browser.providerOptions) == null ? void 0 : _b.actionTimeout) ?? 5e3
|
|
1246
|
+
}
|
|
1247
|
+
/** TODO */
|
|
1248
|
+
).catch((err) => {
|
|
1540
1249
|
console.error("[vitest] Failed to take a screenshot", err);
|
|
1541
1250
|
});
|
|
1542
1251
|
if (screenshot) {
|
|
@@ -1576,7 +1285,7 @@ function createBrowserRunner(runnerClass, mocker, state, coverageModule) {
|
|
|
1576
1285
|
await rpc$2().onAfterSuiteRun({
|
|
1577
1286
|
coverage,
|
|
1578
1287
|
testFiles: files.map((file) => file.name),
|
|
1579
|
-
|
|
1288
|
+
environment: "__browser__",
|
|
1580
1289
|
projectName: this.config.name
|
|
1581
1290
|
});
|
|
1582
1291
|
}
|
|
@@ -1605,8 +1314,8 @@ function createBrowserRunner(runnerClass, mocker, state, coverageModule) {
|
|
|
1605
1314
|
if (!map) {
|
|
1606
1315
|
return rpc$2().onTaskAnnotate(test.id, annotation);
|
|
1607
1316
|
}
|
|
1608
|
-
const traceMap = new TraceMap(map);
|
|
1609
|
-
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);
|
|
1610
1319
|
if (line != null && column != null && source != null) {
|
|
1611
1320
|
let file = annotation.location.file;
|
|
1612
1321
|
if (source) {
|
|
@@ -1662,7 +1371,7 @@ async function initiateRunner(state, mocker, config) {
|
|
|
1662
1371
|
}
|
|
1663
1372
|
const runnerClass = config.mode === "test" ? VitestTestRunner : NodeBenchmarkRunner;
|
|
1664
1373
|
const BrowserRunner = createBrowserRunner(runnerClass, mocker, state, {
|
|
1665
|
-
takeCoverage: () => takeCoverageInsideWorker(config.coverage,
|
|
1374
|
+
takeCoverage: () => takeCoverageInsideWorker(config.coverage, moduleRunner)
|
|
1666
1375
|
});
|
|
1667
1376
|
if (!config.snapshotOptions.snapshotEnvironment) {
|
|
1668
1377
|
config.snapshotOptions.snapshotEnvironment = new VitestBrowserSnapshotEnvironment();
|
|
@@ -1676,8 +1385,8 @@ async function initiateRunner(state, mocker, config) {
|
|
|
1676
1385
|
(_a = runner.cancel) == null ? void 0 : _a.call(runner, reason);
|
|
1677
1386
|
});
|
|
1678
1387
|
const [diffOptions] = await Promise.all([
|
|
1679
|
-
loadDiffConfig(config,
|
|
1680
|
-
loadSnapshotSerializers(config,
|
|
1388
|
+
loadDiffConfig(config, moduleRunner),
|
|
1389
|
+
loadSnapshotSerializers(config, moduleRunner)
|
|
1681
1390
|
]);
|
|
1682
1391
|
runner.config.diffOptions = diffOptions;
|
|
1683
1392
|
getWorkerState().onFilterStackTrace = (stack) => {
|
|
@@ -1698,7 +1407,7 @@ async function getTraceMap(file, sourceMaps) {
|
|
|
1698
1407
|
if (!result) {
|
|
1699
1408
|
return null;
|
|
1700
1409
|
}
|
|
1701
|
-
return new TraceMap(result);
|
|
1410
|
+
return new TraceMap$1(result);
|
|
1702
1411
|
}
|
|
1703
1412
|
async function updateTestFilesLocations(files, sourceMaps) {
|
|
1704
1413
|
const promises2 = files.map(async (file) => {
|
|
@@ -1708,7 +1417,7 @@ async function updateTestFilesLocations(files, sourceMaps) {
|
|
|
1708
1417
|
}
|
|
1709
1418
|
const updateLocation = (task) => {
|
|
1710
1419
|
if (task.location) {
|
|
1711
|
-
const { line, column } = originalPositionFor(traceMap, task.location);
|
|
1420
|
+
const { line, column } = originalPositionFor$1(traceMap, task.location);
|
|
1712
1421
|
if (line != null && column != null) {
|
|
1713
1422
|
task.location = { line, column: task.each ? column : column + 1 };
|
|
1714
1423
|
}
|
|
@@ -1922,6 +1631,9 @@ class MockerRegistry {
|
|
|
1922
1631
|
delete(id) {
|
|
1923
1632
|
this.registryByUrl.delete(id);
|
|
1924
1633
|
}
|
|
1634
|
+
deleteById(id) {
|
|
1635
|
+
this.registryById.delete(id);
|
|
1636
|
+
}
|
|
1925
1637
|
get(id) {
|
|
1926
1638
|
return this.registryByUrl.get(id);
|
|
1927
1639
|
}
|
|
@@ -2040,18 +1752,42 @@ function mockObject(options, object2, mockExports = {}) {
|
|
|
2040
1752
|
return false;
|
|
2041
1753
|
}
|
|
2042
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
|
+
};
|
|
2043
1768
|
const mockPropertiesOf = (container, newContainer) => {
|
|
2044
1769
|
const containerType = getType(container);
|
|
2045
1770
|
const isModule = containerType === "Module" || !!container.__esModule;
|
|
2046
1771
|
for (const { key: property, descriptor } of getAllMockableProperties(container, isModule, options.globalConstructors)) {
|
|
2047
1772
|
if (!isModule && descriptor.get) {
|
|
2048
1773
|
try {
|
|
2049
|
-
|
|
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
|
+
}
|
|
2050
1786
|
} catch {
|
|
2051
1787
|
}
|
|
2052
1788
|
continue;
|
|
2053
1789
|
}
|
|
2054
|
-
if (
|
|
1790
|
+
if (isReadonlyProp(container[property], property)) {
|
|
2055
1791
|
continue;
|
|
2056
1792
|
}
|
|
2057
1793
|
const value = container[property];
|
|
@@ -2062,7 +1798,22 @@ function mockObject(options, object2, mockExports = {}) {
|
|
|
2062
1798
|
}
|
|
2063
1799
|
const type = getType(value);
|
|
2064
1800
|
if (Array.isArray(value)) {
|
|
2065
|
-
|
|
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
|
+
}
|
|
2066
1817
|
continue;
|
|
2067
1818
|
}
|
|
2068
1819
|
const isFunction = type.includes("Function") && typeof value === "function";
|
|
@@ -2070,47 +1821,12 @@ function mockObject(options, object2, mockExports = {}) {
|
|
|
2070
1821
|
define(newContainer, property, value);
|
|
2071
1822
|
continue;
|
|
2072
1823
|
}
|
|
2073
|
-
if (!define(newContainer, property, isFunction ? value : {})) {
|
|
1824
|
+
if (!define(newContainer, property, isFunction || options.type === "autospy" ? value : {})) {
|
|
2074
1825
|
continue;
|
|
2075
1826
|
}
|
|
2076
1827
|
if (isFunction) {
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
for (const { key, descriptor: descriptor2 } of getAllMockableProperties(this, false, options.globalConstructors)) {
|
|
2080
|
-
if (descriptor2.get) {
|
|
2081
|
-
continue;
|
|
2082
|
-
}
|
|
2083
|
-
const value2 = this[key];
|
|
2084
|
-
const type2 = getType(value2);
|
|
2085
|
-
const isFunction2 = type2.includes("Function") && typeof value2 === "function";
|
|
2086
|
-
if (isFunction2) {
|
|
2087
|
-
const original = this[key];
|
|
2088
|
-
const mock2 = spyOn(this, key).mockImplementation(original);
|
|
2089
|
-
const origMockReset = mock2.mockReset;
|
|
2090
|
-
mock2.mockRestore = mock2.mockReset = () => {
|
|
2091
|
-
origMockReset.call(mock2);
|
|
2092
|
-
mock2.mockImplementation(original);
|
|
2093
|
-
return mock2;
|
|
2094
|
-
};
|
|
2095
|
-
}
|
|
2096
|
-
}
|
|
2097
|
-
}
|
|
2098
|
-
};
|
|
2099
|
-
if (!options.spyOn) {
|
|
2100
|
-
throw new Error("[@vitest/mocker] `spyOn` is not defined. This is a Vitest error. Please open a new issue with reproduction.");
|
|
2101
|
-
}
|
|
2102
|
-
const spyOn = options.spyOn;
|
|
2103
|
-
const mock = spyOn(newContainer, property);
|
|
2104
|
-
if (options.type === "automock") {
|
|
2105
|
-
mock.mockImplementation(mockFunction);
|
|
2106
|
-
const origMockReset = mock.mockReset;
|
|
2107
|
-
mock.mockRestore = mock.mockReset = () => {
|
|
2108
|
-
origMockReset.call(mock);
|
|
2109
|
-
mock.mockImplementation(mockFunction);
|
|
2110
|
-
return mock;
|
|
2111
|
-
};
|
|
2112
|
-
}
|
|
2113
|
-
Object.defineProperty(newContainer[property], "length", { value: 0 });
|
|
1828
|
+
const mock = createMock(newContainer[property]);
|
|
1829
|
+
newContainer[property] = mock;
|
|
2114
1830
|
}
|
|
2115
1831
|
refs.track(value, newContainer[property]);
|
|
2116
1832
|
mockPropertiesOf(value, newContainer[property]);
|
|
@@ -2144,14 +1860,15 @@ class RefTracker {
|
|
|
2144
1860
|
function getType(value) {
|
|
2145
1861
|
return Object.prototype.toString.apply(value).slice(8, -1);
|
|
2146
1862
|
}
|
|
2147
|
-
function
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
"
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
"
|
|
2154
|
-
|
|
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;
|
|
2155
1872
|
}
|
|
2156
1873
|
function getAllMockableProperties(obj, isModule, constructors) {
|
|
2157
1874
|
const { Map: Map2, Object: Object2, Function: Function2, RegExp: RegExp2, Array: Array2 } = constructors;
|
|
@@ -2187,6 +1904,20 @@ function collectOwnProperties(obj, collector) {
|
|
|
2187
1904
|
Object.getOwnPropertyNames(obj).forEach(collect);
|
|
2188
1905
|
Object.getOwnPropertySymbols(obj).forEach(collect);
|
|
2189
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
|
+
}
|
|
2190
1921
|
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
2191
1922
|
function normalizeWindowsPath(input = "") {
|
|
2192
1923
|
if (!input) {
|
|
@@ -2669,20 +2400,6 @@ const reactIsMethods = [
|
|
|
2669
2400
|
"isValidElementType"
|
|
2670
2401
|
];
|
|
2671
2402
|
Object.fromEntries(reactIsMethods.map((m) => [m, (v) => ReactIs18[m](v) || ReactIs19[m](v)]));
|
|
2672
|
-
let getPromiseValue = () => "Promise{…}";
|
|
2673
|
-
try {
|
|
2674
|
-
const { getPromiseDetails, kPending, kRejected } = process.binding("util");
|
|
2675
|
-
if (Array.isArray(getPromiseDetails(Promise.resolve()))) {
|
|
2676
|
-
getPromiseValue = (value, options) => {
|
|
2677
|
-
const [state, innerValue] = getPromiseDetails(value);
|
|
2678
|
-
if (state === kPending) {
|
|
2679
|
-
return "Promise{<pending>}";
|
|
2680
|
-
}
|
|
2681
|
-
return `Promise${state === kRejected ? "!" : ""}{${options.inspect(innerValue, options)}}`;
|
|
2682
|
-
};
|
|
2683
|
-
}
|
|
2684
|
-
} catch (notNode) {
|
|
2685
|
-
}
|
|
2686
2403
|
var jsTokens_1;
|
|
2687
2404
|
var hasRequiredJsTokens;
|
|
2688
2405
|
function requireJsTokens() {
|
|
@@ -3147,13 +2864,13 @@ var UrlType;
|
|
|
3147
2864
|
})(UrlType || (UrlType = {}));
|
|
3148
2865
|
const { now } = Date;
|
|
3149
2866
|
class ModuleMocker {
|
|
3150
|
-
constructor(interceptor, rpc2,
|
|
2867
|
+
constructor(interceptor, rpc2, createMockInstance, config) {
|
|
3151
2868
|
__publicField(this, "registry", new MockerRegistry());
|
|
3152
2869
|
__publicField(this, "queue", /* @__PURE__ */ new Set());
|
|
3153
2870
|
__publicField(this, "mockedIds", /* @__PURE__ */ new Set());
|
|
3154
2871
|
this.interceptor = interceptor;
|
|
3155
2872
|
this.rpc = rpc2;
|
|
3156
|
-
this.
|
|
2873
|
+
this.createMockInstance = createMockInstance;
|
|
3157
2874
|
this.config = config;
|
|
3158
2875
|
}
|
|
3159
2876
|
async prepare() {
|
|
@@ -3251,7 +2968,7 @@ class ModuleMocker {
|
|
|
3251
2968
|
Map,
|
|
3252
2969
|
RegExp
|
|
3253
2970
|
},
|
|
3254
|
-
|
|
2971
|
+
createMockInstance: this.createMockInstance,
|
|
3255
2972
|
type: moduleType
|
|
3256
2973
|
}, object2);
|
|
3257
2974
|
}
|
|
@@ -3378,6 +3095,7 @@ class CommandsManager {
|
|
|
3378
3095
|
});
|
|
3379
3096
|
}
|
|
3380
3097
|
}
|
|
3098
|
+
const __vite_import_meta_env__ = { "BASE_URL": "/", "DEV": false, "MODE": "production", "PROD": true, "SSR": false, "VITE_TEST_WATCHER_DEBUG": "false" };
|
|
3381
3099
|
const debugVar = getConfig().env.VITEST_BROWSER_DEBUG;
|
|
3382
3100
|
const debug = debugVar && debugVar !== "false" ? (...args) => {
|
|
3383
3101
|
var _a, _b;
|
|
@@ -3389,7 +3107,7 @@ channel.addEventListener("message", async (e) => {
|
|
|
3389
3107
|
debug == null ? void 0 : debug("event from orchestrator", JSON.stringify(e.data));
|
|
3390
3108
|
if (!isEvent(data)) {
|
|
3391
3109
|
const error = new Error(`Unknown message: ${JSON.stringify(e.data)}`);
|
|
3392
|
-
unhandledError(error, "
|
|
3110
|
+
unhandledError(error, "Unknown Iframe Message");
|
|
3393
3111
|
return;
|
|
3394
3112
|
}
|
|
3395
3113
|
if (!("iframeId" in data) || data.iframeId !== getBrowserState().iframeId) {
|
|
@@ -3399,7 +3117,7 @@ channel.addEventListener("message", async (e) => {
|
|
|
3399
3117
|
case "execute": {
|
|
3400
3118
|
const { method, files, context } = data;
|
|
3401
3119
|
const state = getWorkerState();
|
|
3402
|
-
const parsedContext = parse(context);
|
|
3120
|
+
const parsedContext = parse$1(context);
|
|
3403
3121
|
state.ctx.providedContext = parsedContext;
|
|
3404
3122
|
state.providedContext = parsedContext;
|
|
3405
3123
|
if (method === "collect") {
|
|
@@ -3424,7 +3142,7 @@ channel.addEventListener("message", async (e) => {
|
|
|
3424
3142
|
}
|
|
3425
3143
|
default: {
|
|
3426
3144
|
const error = new Error(`Unknown event: ${data.event}`);
|
|
3427
|
-
unhandledError(error, "
|
|
3145
|
+
unhandledError(error, "Unknown Event");
|
|
3428
3146
|
}
|
|
3429
3147
|
}
|
|
3430
3148
|
channel.postMessage({
|
|
@@ -3433,24 +3151,24 @@ channel.addEventListener("message", async (e) => {
|
|
|
3433
3151
|
});
|
|
3434
3152
|
});
|
|
3435
3153
|
const url = new URL(location.href);
|
|
3436
|
-
const reloadStart = url.searchParams.get("__reloadStart");
|
|
3437
3154
|
const iframeId = url.searchParams.get("iframeId");
|
|
3438
3155
|
const commands = new CommandsManager();
|
|
3439
3156
|
getBrowserState().commands = commands;
|
|
3440
3157
|
getBrowserState().iframeId = iframeId;
|
|
3441
3158
|
let contextSwitched = false;
|
|
3442
3159
|
async function prepareTestEnvironment(options) {
|
|
3443
|
-
debug == null ? void 0 : debug("trying to resolve runner"
|
|
3160
|
+
debug == null ? void 0 : debug("trying to resolve the runner");
|
|
3444
3161
|
const config = getConfig();
|
|
3445
3162
|
const rpc2 = createSafeRpc(client);
|
|
3446
3163
|
const state = getWorkerState();
|
|
3164
|
+
state.metaEnv = __vite_import_meta_env__;
|
|
3447
3165
|
state.onCancel = onCancel;
|
|
3448
3166
|
state.rpc = rpc2;
|
|
3449
3167
|
const interceptor = createModuleMockerInterceptor();
|
|
3450
3168
|
const mocker = new VitestBrowserClientMocker(
|
|
3451
3169
|
interceptor,
|
|
3452
3170
|
rpc2,
|
|
3453
|
-
SpyModule.
|
|
3171
|
+
SpyModule.createMockInstance,
|
|
3454
3172
|
{
|
|
3455
3173
|
root: getBrowserState().viteConfig.root
|
|
3456
3174
|
}
|
|
@@ -3516,7 +3234,7 @@ async function prepare(options) {
|
|
|
3516
3234
|
debug == null ? void 0 : debug("prepare time", state.durations.prepare, "ms");
|
|
3517
3235
|
await Promise.all([
|
|
3518
3236
|
setupCommonEnv(config),
|
|
3519
|
-
startCoverageInsideWorker(config.coverage,
|
|
3237
|
+
startCoverageInsideWorker(config.coverage, moduleRunner, { isolate: config.browser.isolate }),
|
|
3520
3238
|
(async () => {
|
|
3521
3239
|
const VitestIndex = await __vitePreload(() => import("vitest"), true ? [] : void 0);
|
|
3522
3240
|
Object.defineProperty(window, "__vitest_index__", {
|
|
@@ -3525,6 +3243,9 @@ async function prepare(options) {
|
|
|
3525
3243
|
});
|
|
3526
3244
|
})()
|
|
3527
3245
|
]);
|
|
3246
|
+
if (!config.browser.trackUnhandledErrors) {
|
|
3247
|
+
getBrowserState().disposeExceptionTracker();
|
|
3248
|
+
}
|
|
3528
3249
|
}
|
|
3529
3250
|
async function cleanup() {
|
|
3530
3251
|
const state = getWorkerState();
|
|
@@ -3546,7 +3267,7 @@ async function cleanup() {
|
|
|
3546
3267
|
await rpc2.wdioSwitchContext("parent").catch((error) => unhandledError(error, "Cleanup Error"));
|
|
3547
3268
|
}
|
|
3548
3269
|
state.environmentTeardownRun = true;
|
|
3549
|
-
await stopCoverageInsideWorker(config.coverage,
|
|
3270
|
+
await stopCoverageInsideWorker(config.coverage, moduleRunner, { isolate: config.browser.isolate }).catch((error) => {
|
|
3550
3271
|
return unhandledError(error, "Coverage Error");
|
|
3551
3272
|
});
|
|
3552
3273
|
}
|