@vitest/browser 2.0.0-beta.1 → 2.0.0-beta.11
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/context.d.ts +244 -0
- package/context.js +2 -0
- package/dist/client/.vite/manifest.json +24 -0
- package/dist/client/__vitest__/assets/index-BfnqOMHY.js +51 -0
- package/dist/client/__vitest__/assets/index-qZYZB8Y3.css +1 -0
- package/dist/client/__vitest__/index.html +16 -11
- package/dist/client/__vitest_browser__/orchestrator-DQ4hbmZ_.js +338 -0
- package/dist/client/__vitest_browser__/{rpc-By4jD8av.js → rpc-D6HtJ5Rb.js} +310 -399
- package/dist/client/__vitest_browser__/tester-IF8AbWCS.js +837 -0
- package/dist/client/esm-client-injector.js +24 -37
- package/dist/client/{index.html → orchestrator.html} +8 -7
- package/dist/client/{tester.html → tester/tester.html} +13 -3
- package/dist/context.js +175 -0
- package/dist/index.d.ts +103 -4
- package/dist/index.js +1944 -332
- package/dist/providers.js +20 -116
- package/dist/state.js +1 -0
- package/dist/webdriver-BRud6NtS.js +180 -0
- package/package.json +23 -11
- package/providers/playwright.d.ts +36 -2
- package/providers/webdriverio.d.ts +4 -0
- package/providers.d.ts +5 -5
- package/dist/client/__vitest__/assets/index-BMbN3lBu.js +0 -51
- package/dist/client/__vitest__/assets/index-D0Wp7rbG.css +0 -1
- package/dist/client/__vitest_browser__/main-DmAU-Uff.js +0 -102
- package/dist/client/__vitest_browser__/tester-CrKhlp5g.js +0 -473
|
@@ -4,12 +4,7 @@ function __vite__mapDeps(indexes) {
|
|
|
4
4
|
}
|
|
5
5
|
return indexes.map((i) => __vite__mapDeps.viteFileDeps[i])
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
-
var __publicField = (obj, key, value) => {
|
|
10
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
11
|
-
return value;
|
|
12
|
-
};
|
|
7
|
+
import { getSafeTimers } from "/__virtual_vitest__?id=vitest%2Futils";
|
|
13
8
|
(function polyfill() {
|
|
14
9
|
const relList = document.createElement("link").relList;
|
|
15
10
|
if (relList && relList.supports && relList.supports("modulepreload")) {
|
|
@@ -51,6 +46,174 @@ var __publicField = (obj, key, value) => {
|
|
|
51
46
|
fetch(link.href, fetchOpts);
|
|
52
47
|
}
|
|
53
48
|
})();
|
|
49
|
+
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
50
|
+
function normalizeWindowsPath(input = "") {
|
|
51
|
+
if (!input) {
|
|
52
|
+
return input;
|
|
53
|
+
}
|
|
54
|
+
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
55
|
+
}
|
|
56
|
+
const _UNC_REGEX = /^[/\\]{2}/;
|
|
57
|
+
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
58
|
+
const _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
|
|
59
|
+
const _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
|
|
60
|
+
const normalize = function(path) {
|
|
61
|
+
if (path.length === 0) {
|
|
62
|
+
return ".";
|
|
63
|
+
}
|
|
64
|
+
path = normalizeWindowsPath(path);
|
|
65
|
+
const isUNCPath = path.match(_UNC_REGEX);
|
|
66
|
+
const isPathAbsolute = isAbsolute(path);
|
|
67
|
+
const trailingSeparator = path[path.length - 1] === "/";
|
|
68
|
+
path = normalizeString(path, !isPathAbsolute);
|
|
69
|
+
if (path.length === 0) {
|
|
70
|
+
if (isPathAbsolute) {
|
|
71
|
+
return "/";
|
|
72
|
+
}
|
|
73
|
+
return trailingSeparator ? "./" : ".";
|
|
74
|
+
}
|
|
75
|
+
if (trailingSeparator) {
|
|
76
|
+
path += "/";
|
|
77
|
+
}
|
|
78
|
+
if (_DRIVE_LETTER_RE.test(path)) {
|
|
79
|
+
path += "/";
|
|
80
|
+
}
|
|
81
|
+
if (isUNCPath) {
|
|
82
|
+
if (!isPathAbsolute) {
|
|
83
|
+
return `//./${path}`;
|
|
84
|
+
}
|
|
85
|
+
return `//${path}`;
|
|
86
|
+
}
|
|
87
|
+
return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
|
|
88
|
+
};
|
|
89
|
+
const join = function(...arguments_) {
|
|
90
|
+
if (arguments_.length === 0) {
|
|
91
|
+
return ".";
|
|
92
|
+
}
|
|
93
|
+
let joined;
|
|
94
|
+
for (const argument of arguments_) {
|
|
95
|
+
if (argument && argument.length > 0) {
|
|
96
|
+
if (joined === void 0) {
|
|
97
|
+
joined = argument;
|
|
98
|
+
} else {
|
|
99
|
+
joined += `/${argument}`;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (joined === void 0) {
|
|
104
|
+
return ".";
|
|
105
|
+
}
|
|
106
|
+
return normalize(joined.replace(/\/\/+/g, "/"));
|
|
107
|
+
};
|
|
108
|
+
function cwd() {
|
|
109
|
+
if (typeof process !== "undefined" && typeof process.cwd === "function") {
|
|
110
|
+
return process.cwd().replace(/\\/g, "/");
|
|
111
|
+
}
|
|
112
|
+
return "/";
|
|
113
|
+
}
|
|
114
|
+
const resolve = function(...arguments_) {
|
|
115
|
+
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
|
|
116
|
+
let resolvedPath = "";
|
|
117
|
+
let resolvedAbsolute = false;
|
|
118
|
+
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
|
119
|
+
const path = index >= 0 ? arguments_[index] : cwd();
|
|
120
|
+
if (!path || path.length === 0) {
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
resolvedPath = `${path}/${resolvedPath}`;
|
|
124
|
+
resolvedAbsolute = isAbsolute(path);
|
|
125
|
+
}
|
|
126
|
+
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
|
127
|
+
if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
|
|
128
|
+
return `/${resolvedPath}`;
|
|
129
|
+
}
|
|
130
|
+
return resolvedPath.length > 0 ? resolvedPath : ".";
|
|
131
|
+
};
|
|
132
|
+
function normalizeString(path, allowAboveRoot) {
|
|
133
|
+
let res = "";
|
|
134
|
+
let lastSegmentLength = 0;
|
|
135
|
+
let lastSlash = -1;
|
|
136
|
+
let dots = 0;
|
|
137
|
+
let char = null;
|
|
138
|
+
for (let index = 0; index <= path.length; ++index) {
|
|
139
|
+
if (index < path.length) {
|
|
140
|
+
char = path[index];
|
|
141
|
+
} else if (char === "/") {
|
|
142
|
+
break;
|
|
143
|
+
} else {
|
|
144
|
+
char = "/";
|
|
145
|
+
}
|
|
146
|
+
if (char === "/") {
|
|
147
|
+
if (lastSlash === index - 1 || dots === 1)
|
|
148
|
+
;
|
|
149
|
+
else if (dots === 2) {
|
|
150
|
+
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
151
|
+
if (res.length > 2) {
|
|
152
|
+
const lastSlashIndex = res.lastIndexOf("/");
|
|
153
|
+
if (lastSlashIndex === -1) {
|
|
154
|
+
res = "";
|
|
155
|
+
lastSegmentLength = 0;
|
|
156
|
+
} else {
|
|
157
|
+
res = res.slice(0, lastSlashIndex);
|
|
158
|
+
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
159
|
+
}
|
|
160
|
+
lastSlash = index;
|
|
161
|
+
dots = 0;
|
|
162
|
+
continue;
|
|
163
|
+
} else if (res.length > 0) {
|
|
164
|
+
res = "";
|
|
165
|
+
lastSegmentLength = 0;
|
|
166
|
+
lastSlash = index;
|
|
167
|
+
dots = 0;
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
if (allowAboveRoot) {
|
|
172
|
+
res += res.length > 0 ? "/.." : "..";
|
|
173
|
+
lastSegmentLength = 2;
|
|
174
|
+
}
|
|
175
|
+
} else {
|
|
176
|
+
if (res.length > 0) {
|
|
177
|
+
res += `/${path.slice(lastSlash + 1, index)}`;
|
|
178
|
+
} else {
|
|
179
|
+
res = path.slice(lastSlash + 1, index);
|
|
180
|
+
}
|
|
181
|
+
lastSegmentLength = index - lastSlash - 1;
|
|
182
|
+
}
|
|
183
|
+
lastSlash = index;
|
|
184
|
+
dots = 0;
|
|
185
|
+
} else if (char === "." && dots !== -1) {
|
|
186
|
+
++dots;
|
|
187
|
+
} else {
|
|
188
|
+
dots = -1;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return res;
|
|
192
|
+
}
|
|
193
|
+
const isAbsolute = function(p) {
|
|
194
|
+
return _IS_ABSOLUTE_RE.test(p);
|
|
195
|
+
};
|
|
196
|
+
const _EXTNAME_RE = /.(\.[^./]+)$/;
|
|
197
|
+
const extname = function(p) {
|
|
198
|
+
const match = _EXTNAME_RE.exec(normalizeWindowsPath(p));
|
|
199
|
+
return match && match[1] || "";
|
|
200
|
+
};
|
|
201
|
+
const relative = function(from, to) {
|
|
202
|
+
const _from = resolve(from).replace(_ROOT_FOLDER_RE, "$1").split("/");
|
|
203
|
+
const _to = resolve(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
|
|
204
|
+
if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) {
|
|
205
|
+
return _to.join("/");
|
|
206
|
+
}
|
|
207
|
+
const _fromCopy = [..._from];
|
|
208
|
+
for (const segment of _fromCopy) {
|
|
209
|
+
if (_to[0] !== segment) {
|
|
210
|
+
break;
|
|
211
|
+
}
|
|
212
|
+
_from.shift();
|
|
213
|
+
_to.shift();
|
|
214
|
+
}
|
|
215
|
+
return [..._from.map(() => ".."), ..._to].join("/");
|
|
216
|
+
};
|
|
54
217
|
const DEFAULT_TIMEOUT = 6e4;
|
|
55
218
|
function defaultSerialize(i) {
|
|
56
219
|
return i;
|
|
@@ -225,381 +388,6 @@ const stringify = (value, replacer, space) => {
|
|
|
225
388
|
return after;
|
|
226
389
|
}
|
|
227
390
|
};
|
|
228
|
-
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
229
|
-
function normalizeWindowsPath(input = "") {
|
|
230
|
-
if (!input) {
|
|
231
|
-
return input;
|
|
232
|
-
}
|
|
233
|
-
return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
|
|
234
|
-
}
|
|
235
|
-
const _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/;
|
|
236
|
-
const _ROOT_FOLDER_RE = /^\/([A-Za-z]:)?$/;
|
|
237
|
-
function cwd() {
|
|
238
|
-
if (typeof process !== "undefined" && typeof process.cwd === "function") {
|
|
239
|
-
return process.cwd().replace(/\\/g, "/");
|
|
240
|
-
}
|
|
241
|
-
return "/";
|
|
242
|
-
}
|
|
243
|
-
const resolve = function(...arguments_) {
|
|
244
|
-
arguments_ = arguments_.map((argument) => normalizeWindowsPath(argument));
|
|
245
|
-
let resolvedPath = "";
|
|
246
|
-
let resolvedAbsolute = false;
|
|
247
|
-
for (let index = arguments_.length - 1; index >= -1 && !resolvedAbsolute; index--) {
|
|
248
|
-
const path = index >= 0 ? arguments_[index] : cwd();
|
|
249
|
-
if (!path || path.length === 0) {
|
|
250
|
-
continue;
|
|
251
|
-
}
|
|
252
|
-
resolvedPath = `${path}/${resolvedPath}`;
|
|
253
|
-
resolvedAbsolute = isAbsolute(path);
|
|
254
|
-
}
|
|
255
|
-
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute);
|
|
256
|
-
if (resolvedAbsolute && !isAbsolute(resolvedPath)) {
|
|
257
|
-
return `/${resolvedPath}`;
|
|
258
|
-
}
|
|
259
|
-
return resolvedPath.length > 0 ? resolvedPath : ".";
|
|
260
|
-
};
|
|
261
|
-
function normalizeString(path, allowAboveRoot) {
|
|
262
|
-
let res = "";
|
|
263
|
-
let lastSegmentLength = 0;
|
|
264
|
-
let lastSlash = -1;
|
|
265
|
-
let dots = 0;
|
|
266
|
-
let char = null;
|
|
267
|
-
for (let index = 0; index <= path.length; ++index) {
|
|
268
|
-
if (index < path.length) {
|
|
269
|
-
char = path[index];
|
|
270
|
-
} else if (char === "/") {
|
|
271
|
-
break;
|
|
272
|
-
} else {
|
|
273
|
-
char = "/";
|
|
274
|
-
}
|
|
275
|
-
if (char === "/") {
|
|
276
|
-
if (lastSlash === index - 1 || dots === 1)
|
|
277
|
-
;
|
|
278
|
-
else if (dots === 2) {
|
|
279
|
-
if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
|
|
280
|
-
if (res.length > 2) {
|
|
281
|
-
const lastSlashIndex = res.lastIndexOf("/");
|
|
282
|
-
if (lastSlashIndex === -1) {
|
|
283
|
-
res = "";
|
|
284
|
-
lastSegmentLength = 0;
|
|
285
|
-
} else {
|
|
286
|
-
res = res.slice(0, lastSlashIndex);
|
|
287
|
-
lastSegmentLength = res.length - 1 - res.lastIndexOf("/");
|
|
288
|
-
}
|
|
289
|
-
lastSlash = index;
|
|
290
|
-
dots = 0;
|
|
291
|
-
continue;
|
|
292
|
-
} else if (res.length > 0) {
|
|
293
|
-
res = "";
|
|
294
|
-
lastSegmentLength = 0;
|
|
295
|
-
lastSlash = index;
|
|
296
|
-
dots = 0;
|
|
297
|
-
continue;
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
if (allowAboveRoot) {
|
|
301
|
-
res += res.length > 0 ? "/.." : "..";
|
|
302
|
-
lastSegmentLength = 2;
|
|
303
|
-
}
|
|
304
|
-
} else {
|
|
305
|
-
if (res.length > 0) {
|
|
306
|
-
res += `/${path.slice(lastSlash + 1, index)}`;
|
|
307
|
-
} else {
|
|
308
|
-
res = path.slice(lastSlash + 1, index);
|
|
309
|
-
}
|
|
310
|
-
lastSegmentLength = index - lastSlash - 1;
|
|
311
|
-
}
|
|
312
|
-
lastSlash = index;
|
|
313
|
-
dots = 0;
|
|
314
|
-
} else if (char === "." && dots !== -1) {
|
|
315
|
-
++dots;
|
|
316
|
-
} else {
|
|
317
|
-
dots = -1;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
return res;
|
|
321
|
-
}
|
|
322
|
-
const isAbsolute = function(p) {
|
|
323
|
-
return _IS_ABSOLUTE_RE.test(p);
|
|
324
|
-
};
|
|
325
|
-
const relative = function(from, to) {
|
|
326
|
-
const _from = resolve(from).replace(_ROOT_FOLDER_RE, "$1").split("/");
|
|
327
|
-
const _to = resolve(to).replace(_ROOT_FOLDER_RE, "$1").split("/");
|
|
328
|
-
if (_to[0][1] === ":" && _from[0][1] === ":" && _from[0] !== _to[0]) {
|
|
329
|
-
return _to.join("/");
|
|
330
|
-
}
|
|
331
|
-
const _fromCopy = [..._from];
|
|
332
|
-
for (const segment of _fromCopy) {
|
|
333
|
-
if (_to[0] !== segment) {
|
|
334
|
-
break;
|
|
335
|
-
}
|
|
336
|
-
_from.shift();
|
|
337
|
-
_to.shift();
|
|
338
|
-
}
|
|
339
|
-
return [..._from.map(() => ".."), ..._to].join("/");
|
|
340
|
-
};
|
|
341
|
-
function isAggregateError(err) {
|
|
342
|
-
if (typeof AggregateError !== "undefined" && err instanceof AggregateError)
|
|
343
|
-
return true;
|
|
344
|
-
return err instanceof Error && "errors" in err;
|
|
345
|
-
}
|
|
346
|
-
class StateManager {
|
|
347
|
-
constructor() {
|
|
348
|
-
__publicField(this, "filesMap", /* @__PURE__ */ new Map());
|
|
349
|
-
__publicField(this, "pathsSet", /* @__PURE__ */ new Set());
|
|
350
|
-
__publicField(this, "idMap", /* @__PURE__ */ new Map());
|
|
351
|
-
__publicField(this, "taskFileMap", /* @__PURE__ */ new WeakMap());
|
|
352
|
-
__publicField(this, "errorsSet", /* @__PURE__ */ new Set());
|
|
353
|
-
__publicField(this, "processTimeoutCauses", /* @__PURE__ */ new Set());
|
|
354
|
-
}
|
|
355
|
-
catchError(err, type) {
|
|
356
|
-
if (isAggregateError(err))
|
|
357
|
-
return err.errors.forEach((error) => this.catchError(error, type));
|
|
358
|
-
if (err === Object(err))
|
|
359
|
-
err.type = type;
|
|
360
|
-
else
|
|
361
|
-
err = { type, message: err };
|
|
362
|
-
const _err = err;
|
|
363
|
-
if (_err && typeof _err === "object" && _err.code === "VITEST_PENDING") {
|
|
364
|
-
const task = this.idMap.get(_err.taskId);
|
|
365
|
-
if (task) {
|
|
366
|
-
task.mode = "skip";
|
|
367
|
-
task.result ?? (task.result = { state: "skip" });
|
|
368
|
-
task.result.state = "skip";
|
|
369
|
-
}
|
|
370
|
-
return;
|
|
371
|
-
}
|
|
372
|
-
this.errorsSet.add(err);
|
|
373
|
-
}
|
|
374
|
-
clearErrors() {
|
|
375
|
-
this.errorsSet.clear();
|
|
376
|
-
}
|
|
377
|
-
getUnhandledErrors() {
|
|
378
|
-
return Array.from(this.errorsSet.values());
|
|
379
|
-
}
|
|
380
|
-
addProcessTimeoutCause(cause) {
|
|
381
|
-
this.processTimeoutCauses.add(cause);
|
|
382
|
-
}
|
|
383
|
-
getProcessTimeoutCauses() {
|
|
384
|
-
return Array.from(this.processTimeoutCauses.values());
|
|
385
|
-
}
|
|
386
|
-
getPaths() {
|
|
387
|
-
return Array.from(this.pathsSet);
|
|
388
|
-
}
|
|
389
|
-
getFiles(keys2) {
|
|
390
|
-
if (keys2)
|
|
391
|
-
return keys2.map((key) => this.filesMap.get(key)).filter(Boolean).flat();
|
|
392
|
-
return Array.from(this.filesMap.values()).flat();
|
|
393
|
-
}
|
|
394
|
-
getFilepaths() {
|
|
395
|
-
return Array.from(this.filesMap.keys());
|
|
396
|
-
}
|
|
397
|
-
getFailedFilepaths() {
|
|
398
|
-
return this.getFiles().filter((i) => {
|
|
399
|
-
var _a;
|
|
400
|
-
return ((_a = i.result) == null ? void 0 : _a.state) === "fail";
|
|
401
|
-
}).map((i) => i.filepath);
|
|
402
|
-
}
|
|
403
|
-
collectPaths(paths = []) {
|
|
404
|
-
paths.forEach((path) => {
|
|
405
|
-
this.pathsSet.add(path);
|
|
406
|
-
});
|
|
407
|
-
}
|
|
408
|
-
collectFiles(files = []) {
|
|
409
|
-
files.forEach((file) => {
|
|
410
|
-
const existing = this.filesMap.get(file.filepath) || [];
|
|
411
|
-
const otherProject = existing.filter((i) => i.projectName !== file.projectName);
|
|
412
|
-
otherProject.push(file);
|
|
413
|
-
this.filesMap.set(file.filepath, otherProject);
|
|
414
|
-
this.updateId(file);
|
|
415
|
-
});
|
|
416
|
-
}
|
|
417
|
-
// this file is reused by ws-client, and shoult not rely on heavy dependencies like workspace
|
|
418
|
-
clearFiles(_project, paths = []) {
|
|
419
|
-
const project = _project;
|
|
420
|
-
paths.forEach((path) => {
|
|
421
|
-
const files = this.filesMap.get(path);
|
|
422
|
-
if (!files)
|
|
423
|
-
return;
|
|
424
|
-
const filtered = files.filter((file) => file.projectName !== project.config.name);
|
|
425
|
-
if (!filtered.length)
|
|
426
|
-
this.filesMap.delete(path);
|
|
427
|
-
else
|
|
428
|
-
this.filesMap.set(path, filtered);
|
|
429
|
-
});
|
|
430
|
-
}
|
|
431
|
-
updateId(task) {
|
|
432
|
-
if (this.idMap.get(task.id) === task)
|
|
433
|
-
return;
|
|
434
|
-
this.idMap.set(task.id, task);
|
|
435
|
-
if (task.type === "suite") {
|
|
436
|
-
task.tasks.forEach((task2) => {
|
|
437
|
-
this.updateId(task2);
|
|
438
|
-
});
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
updateTasks(packs) {
|
|
442
|
-
for (const [id, result, meta] of packs) {
|
|
443
|
-
const task = this.idMap.get(id);
|
|
444
|
-
if (task) {
|
|
445
|
-
task.result = result;
|
|
446
|
-
task.meta = meta;
|
|
447
|
-
if ((result == null ? void 0 : result.state) === "skip")
|
|
448
|
-
task.mode = "skip";
|
|
449
|
-
}
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
updateUserLog(log) {
|
|
453
|
-
const task = log.taskId && this.idMap.get(log.taskId);
|
|
454
|
-
if (task) {
|
|
455
|
-
if (!task.logs)
|
|
456
|
-
task.logs = [];
|
|
457
|
-
task.logs.push(log);
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
getCountOfFailedTests() {
|
|
461
|
-
return Array.from(this.idMap.values()).filter((t) => {
|
|
462
|
-
var _a;
|
|
463
|
-
return ((_a = t.result) == null ? void 0 : _a.state) === "fail";
|
|
464
|
-
}).length;
|
|
465
|
-
}
|
|
466
|
-
cancelFiles(files, root, projectName) {
|
|
467
|
-
this.collectFiles(files.map((filepath) => {
|
|
468
|
-
const file = {
|
|
469
|
-
filepath,
|
|
470
|
-
name: relative(root, filepath),
|
|
471
|
-
id: filepath,
|
|
472
|
-
mode: "skip",
|
|
473
|
-
type: "suite",
|
|
474
|
-
result: {
|
|
475
|
-
state: "skip"
|
|
476
|
-
},
|
|
477
|
-
meta: {},
|
|
478
|
-
// Cancelled files have not yet collected tests
|
|
479
|
-
tasks: [],
|
|
480
|
-
projectName,
|
|
481
|
-
file: null
|
|
482
|
-
};
|
|
483
|
-
file.file = file;
|
|
484
|
-
return file;
|
|
485
|
-
}));
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
function createClient(url, options = {}) {
|
|
489
|
-
const {
|
|
490
|
-
handlers = {},
|
|
491
|
-
autoReconnect = true,
|
|
492
|
-
reconnectInterval = 2e3,
|
|
493
|
-
reconnectTries = 10,
|
|
494
|
-
connectTimeout = 6e4,
|
|
495
|
-
reactive = (v) => v,
|
|
496
|
-
WebSocketConstructor = globalThis.WebSocket
|
|
497
|
-
} = options;
|
|
498
|
-
let tries = reconnectTries;
|
|
499
|
-
const ctx = reactive({
|
|
500
|
-
ws: new WebSocketConstructor(url),
|
|
501
|
-
state: new StateManager(),
|
|
502
|
-
waitForConnection,
|
|
503
|
-
reconnect
|
|
504
|
-
});
|
|
505
|
-
ctx.state.filesMap = reactive(ctx.state.filesMap);
|
|
506
|
-
ctx.state.idMap = reactive(ctx.state.idMap);
|
|
507
|
-
let onMessage;
|
|
508
|
-
const functions = {
|
|
509
|
-
onPathsCollected(paths) {
|
|
510
|
-
var _a;
|
|
511
|
-
ctx.state.collectPaths(paths);
|
|
512
|
-
(_a = handlers.onPathsCollected) == null ? void 0 : _a.call(handlers, paths);
|
|
513
|
-
},
|
|
514
|
-
onCollected(files) {
|
|
515
|
-
var _a;
|
|
516
|
-
ctx.state.collectFiles(files);
|
|
517
|
-
(_a = handlers.onCollected) == null ? void 0 : _a.call(handlers, files);
|
|
518
|
-
},
|
|
519
|
-
onTaskUpdate(packs) {
|
|
520
|
-
var _a;
|
|
521
|
-
ctx.state.updateTasks(packs);
|
|
522
|
-
(_a = handlers.onTaskUpdate) == null ? void 0 : _a.call(handlers, packs);
|
|
523
|
-
},
|
|
524
|
-
onUserConsoleLog(log) {
|
|
525
|
-
ctx.state.updateUserLog(log);
|
|
526
|
-
},
|
|
527
|
-
onFinished(files, errors) {
|
|
528
|
-
var _a;
|
|
529
|
-
(_a = handlers.onFinished) == null ? void 0 : _a.call(handlers, files, errors);
|
|
530
|
-
},
|
|
531
|
-
onFinishedReportCoverage() {
|
|
532
|
-
var _a;
|
|
533
|
-
(_a = handlers.onFinishedReportCoverage) == null ? void 0 : _a.call(handlers);
|
|
534
|
-
},
|
|
535
|
-
onCancel(reason) {
|
|
536
|
-
var _a;
|
|
537
|
-
(_a = handlers.onCancel) == null ? void 0 : _a.call(handlers, reason);
|
|
538
|
-
}
|
|
539
|
-
};
|
|
540
|
-
const birpcHandlers = {
|
|
541
|
-
post: (msg) => ctx.ws.send(msg),
|
|
542
|
-
on: (fn) => onMessage = fn,
|
|
543
|
-
serialize: stringify,
|
|
544
|
-
deserialize: parse,
|
|
545
|
-
onTimeoutError(functionName) {
|
|
546
|
-
throw new Error(`[vitest-ws-client]: Timeout calling "${functionName}"`);
|
|
547
|
-
}
|
|
548
|
-
};
|
|
549
|
-
ctx.rpc = createBirpc(
|
|
550
|
-
functions,
|
|
551
|
-
birpcHandlers
|
|
552
|
-
);
|
|
553
|
-
let openPromise;
|
|
554
|
-
function reconnect(reset = false) {
|
|
555
|
-
if (reset)
|
|
556
|
-
tries = reconnectTries;
|
|
557
|
-
ctx.ws = new WebSocketConstructor(url);
|
|
558
|
-
registerWS();
|
|
559
|
-
}
|
|
560
|
-
function registerWS() {
|
|
561
|
-
openPromise = new Promise((resolve2, reject) => {
|
|
562
|
-
var _a, _b;
|
|
563
|
-
const timeout = (_b = (_a = setTimeout(() => {
|
|
564
|
-
reject(new Error(`Cannot connect to the server in ${connectTimeout / 1e3} seconds`));
|
|
565
|
-
}, connectTimeout)) == null ? void 0 : _a.unref) == null ? void 0 : _b.call(_a);
|
|
566
|
-
if (ctx.ws.OPEN === ctx.ws.readyState)
|
|
567
|
-
resolve2();
|
|
568
|
-
ctx.ws.addEventListener("open", () => {
|
|
569
|
-
tries = reconnectTries;
|
|
570
|
-
resolve2();
|
|
571
|
-
clearTimeout(timeout);
|
|
572
|
-
});
|
|
573
|
-
});
|
|
574
|
-
ctx.ws.addEventListener("message", (v) => {
|
|
575
|
-
onMessage(v.data);
|
|
576
|
-
});
|
|
577
|
-
ctx.ws.addEventListener("close", () => {
|
|
578
|
-
tries -= 1;
|
|
579
|
-
if (autoReconnect && tries > 0)
|
|
580
|
-
setTimeout(reconnect, reconnectInterval);
|
|
581
|
-
});
|
|
582
|
-
}
|
|
583
|
-
registerWS();
|
|
584
|
-
function waitForConnection() {
|
|
585
|
-
return openPromise;
|
|
586
|
-
}
|
|
587
|
-
return ctx;
|
|
588
|
-
}
|
|
589
|
-
const PORT = location.port;
|
|
590
|
-
const HOST = [location.hostname, PORT].filter(Boolean).join(":");
|
|
591
|
-
const ENTRY_URL = `${location.protocol === "https:" ? "wss:" : "ws:"}//${HOST}/__vitest_api__`;
|
|
592
|
-
let setCancel = (_) => {
|
|
593
|
-
};
|
|
594
|
-
const onCancel = new Promise((resolve2) => {
|
|
595
|
-
setCancel = resolve2;
|
|
596
|
-
});
|
|
597
|
-
const client = createClient(ENTRY_URL, {
|
|
598
|
-
handlers: {
|
|
599
|
-
onCancel: setCancel
|
|
600
|
-
}
|
|
601
|
-
});
|
|
602
|
-
const channel = new BroadcastChannel("vitest");
|
|
603
391
|
const scriptRel = "modulepreload";
|
|
604
392
|
const assetsURL = function(dep) {
|
|
605
393
|
return "/" + dep;
|
|
@@ -650,15 +438,135 @@ const __vitePreload = function preload(baseModule, deps, importerUrl) {
|
|
|
650
438
|
});
|
|
651
439
|
};
|
|
652
440
|
async function importId(id) {
|
|
653
|
-
const name =
|
|
654
|
-
return getBrowserState().wrapModule(__vitePreload(() => import(name), true ? __vite__mapDeps([]) : void 0));
|
|
441
|
+
const name = `/@id/${id}`;
|
|
442
|
+
return (/* @__PURE__ */ getBrowserState()).wrapModule(() => __vitePreload(() => import(name), true ? __vite__mapDeps([]) : void 0));
|
|
655
443
|
}
|
|
656
444
|
function getConfig() {
|
|
657
|
-
return getBrowserState().config;
|
|
445
|
+
return (/* @__PURE__ */ getBrowserState()).config;
|
|
658
446
|
}
|
|
447
|
+
// @__NO_SIDE_EFFECTS__
|
|
659
448
|
function getBrowserState() {
|
|
660
449
|
return window.__vitest_browser_runner__;
|
|
661
450
|
}
|
|
451
|
+
// @__NO_SIDE_EFFECTS__
|
|
452
|
+
function getWorkerState() {
|
|
453
|
+
const state = window.__vitest_worker__;
|
|
454
|
+
if (!state) {
|
|
455
|
+
throw new Error("Worker state is not found. This is an issue with Vitest. Please, open an issue.");
|
|
456
|
+
}
|
|
457
|
+
return state;
|
|
458
|
+
}
|
|
459
|
+
const channel = new BroadcastChannel(
|
|
460
|
+
`vitest:${(/* @__PURE__ */ getBrowserState()).contextId}`
|
|
461
|
+
);
|
|
462
|
+
function waitForChannel(event) {
|
|
463
|
+
return new Promise((resolve2) => {
|
|
464
|
+
channel.addEventListener(
|
|
465
|
+
"message",
|
|
466
|
+
(e) => {
|
|
467
|
+
var _a;
|
|
468
|
+
if (((_a = e.data) == null ? void 0 : _a.type) === event) {
|
|
469
|
+
resolve2();
|
|
470
|
+
}
|
|
471
|
+
},
|
|
472
|
+
{ once: true }
|
|
473
|
+
);
|
|
474
|
+
});
|
|
475
|
+
}
|
|
476
|
+
const PAGE_TYPE = (/* @__PURE__ */ getBrowserState()).type;
|
|
477
|
+
const PORT = location.port;
|
|
478
|
+
const HOST = [location.hostname, PORT].filter(Boolean).join(":");
|
|
479
|
+
const SESSION_ID = PAGE_TYPE === "orchestrator" ? (/* @__PURE__ */ getBrowserState()).contextId : crypto.randomUUID();
|
|
480
|
+
const ENTRY_URL = `${location.protocol === "https:" ? "wss:" : "ws:"}//${HOST}/__vitest_browser_api__?type=${PAGE_TYPE}&sessionId=${SESSION_ID}`;
|
|
481
|
+
let setCancel = (_) => {
|
|
482
|
+
};
|
|
483
|
+
const onCancel = new Promise((resolve2) => {
|
|
484
|
+
setCancel = resolve2;
|
|
485
|
+
});
|
|
486
|
+
function createClient() {
|
|
487
|
+
const reconnectInterval = 2e3;
|
|
488
|
+
const reconnectTries = 10;
|
|
489
|
+
const connectTimeout = 6e4;
|
|
490
|
+
let tries = reconnectTries;
|
|
491
|
+
const ctx = {
|
|
492
|
+
ws: new WebSocket(ENTRY_URL),
|
|
493
|
+
waitForConnection
|
|
494
|
+
};
|
|
495
|
+
let onMessage;
|
|
496
|
+
ctx.rpc = createBirpc(
|
|
497
|
+
{
|
|
498
|
+
onCancel: setCancel,
|
|
499
|
+
async createTesters(files) {
|
|
500
|
+
var _a, _b;
|
|
501
|
+
if (PAGE_TYPE !== "orchestrator") {
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
(_b = (_a = /* @__PURE__ */ getBrowserState()).createTesters) == null ? void 0 : _b.call(_a, files);
|
|
505
|
+
}
|
|
506
|
+
},
|
|
507
|
+
{
|
|
508
|
+
post: (msg) => ctx.ws.send(msg),
|
|
509
|
+
on: (fn) => onMessage = fn,
|
|
510
|
+
serialize: (e) => stringify(e, (_, v) => {
|
|
511
|
+
if (v instanceof Error) {
|
|
512
|
+
return {
|
|
513
|
+
name: v.name,
|
|
514
|
+
message: v.message,
|
|
515
|
+
stack: v.stack
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
return v;
|
|
519
|
+
}),
|
|
520
|
+
deserialize: parse,
|
|
521
|
+
onTimeoutError(functionName) {
|
|
522
|
+
throw new Error(`[vitest-browser]: Timeout calling "${functionName}"`);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
);
|
|
526
|
+
let openPromise;
|
|
527
|
+
function reconnect(reset = false) {
|
|
528
|
+
if (reset) {
|
|
529
|
+
tries = reconnectTries;
|
|
530
|
+
}
|
|
531
|
+
ctx.ws = new WebSocket(ENTRY_URL);
|
|
532
|
+
registerWS();
|
|
533
|
+
}
|
|
534
|
+
function registerWS() {
|
|
535
|
+
openPromise = new Promise((resolve2, reject) => {
|
|
536
|
+
var _a, _b;
|
|
537
|
+
const timeout = (_b = (_a = setTimeout(() => {
|
|
538
|
+
reject(
|
|
539
|
+
new Error(
|
|
540
|
+
`Cannot connect to the server in ${connectTimeout / 1e3} seconds`
|
|
541
|
+
)
|
|
542
|
+
);
|
|
543
|
+
}, connectTimeout)) == null ? void 0 : _a.unref) == null ? void 0 : _b.call(_a);
|
|
544
|
+
if (ctx.ws.OPEN === ctx.ws.readyState) {
|
|
545
|
+
resolve2();
|
|
546
|
+
}
|
|
547
|
+
ctx.ws.addEventListener("open", () => {
|
|
548
|
+
tries = reconnectTries;
|
|
549
|
+
resolve2();
|
|
550
|
+
clearTimeout(timeout);
|
|
551
|
+
});
|
|
552
|
+
});
|
|
553
|
+
ctx.ws.addEventListener("message", (v) => {
|
|
554
|
+
onMessage(v.data);
|
|
555
|
+
});
|
|
556
|
+
ctx.ws.addEventListener("close", () => {
|
|
557
|
+
tries -= 1;
|
|
558
|
+
if (tries > 0) {
|
|
559
|
+
setTimeout(reconnect, reconnectInterval);
|
|
560
|
+
}
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
registerWS();
|
|
564
|
+
function waitForConnection() {
|
|
565
|
+
return openPromise;
|
|
566
|
+
}
|
|
567
|
+
return ctx;
|
|
568
|
+
}
|
|
569
|
+
const client = createClient();
|
|
662
570
|
const { get } = Reflect;
|
|
663
571
|
function withSafeTimers(getTimers, fn) {
|
|
664
572
|
const { setTimeout: setTimeout2, clearTimeout: clearTimeout2, setImmediate, clearImmediate } = getTimers();
|
|
@@ -682,18 +590,20 @@ function withSafeTimers(getTimers, fn) {
|
|
|
682
590
|
}
|
|
683
591
|
const promises = /* @__PURE__ */ new Set();
|
|
684
592
|
async function rpcDone() {
|
|
685
|
-
if (!promises.size)
|
|
593
|
+
if (!promises.size) {
|
|
686
594
|
return;
|
|
595
|
+
}
|
|
687
596
|
const awaitable = Array.from(promises);
|
|
688
597
|
return Promise.all(awaitable);
|
|
689
598
|
}
|
|
690
|
-
function createSafeRpc(client2
|
|
599
|
+
function createSafeRpc(client2) {
|
|
691
600
|
return new Proxy(client2.rpc, {
|
|
692
601
|
get(target, p, handler) {
|
|
693
|
-
if (p === "then")
|
|
602
|
+
if (p === "then") {
|
|
694
603
|
return;
|
|
604
|
+
}
|
|
695
605
|
const sendCall = get(target, p, handler);
|
|
696
|
-
const safeSendCall = (...args) => withSafeTimers(
|
|
606
|
+
const safeSendCall = (...args) => withSafeTimers(getSafeTimers, async () => {
|
|
697
607
|
const result = sendCall(...args);
|
|
698
608
|
promises.add(result);
|
|
699
609
|
try {
|
|
@@ -707,22 +617,23 @@ function createSafeRpc(client2, getTimers) {
|
|
|
707
617
|
}
|
|
708
618
|
});
|
|
709
619
|
}
|
|
710
|
-
async function loadSafeRpc(client2) {
|
|
711
|
-
const { getSafeTimers } = await importId("vitest/utils");
|
|
712
|
-
return createSafeRpc(client2, getSafeTimers);
|
|
713
|
-
}
|
|
714
620
|
function rpc() {
|
|
715
621
|
return globalThis.__vitest_worker__.rpc;
|
|
716
622
|
}
|
|
717
623
|
export {
|
|
718
624
|
__vitePreload as _,
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
625
|
+
client as a,
|
|
626
|
+
getConfig as b,
|
|
627
|
+
channel as c,
|
|
628
|
+
rpcDone as d,
|
|
629
|
+
rpc as e,
|
|
630
|
+
extname as f,
|
|
631
|
+
getBrowserState as g,
|
|
632
|
+
createSafeRpc as h,
|
|
724
633
|
importId as i,
|
|
725
|
-
|
|
634
|
+
join as j,
|
|
635
|
+
getWorkerState as k,
|
|
726
636
|
onCancel as o,
|
|
727
|
-
|
|
637
|
+
relative as r,
|
|
638
|
+
waitForChannel as w
|
|
728
639
|
};
|