@vitest/browser 5.0.0-beta.5 → 5.0.0-beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/.vite/manifest.json +6 -6
- package/dist/client/__vitest_browser__/{orchestrator-bDJB3Bid.js → orchestrator-pKob2Z-i.js} +51 -12
- package/dist/client/__vitest_browser__/rrweb-snapshot-DkFyu2W8.js +4665 -0
- package/dist/client/__vitest_browser__/{tester-C1kIlbPd.js → tester-DdZeFrjo.js} +53 -41
- package/dist/client/orchestrator.html +1 -1
- package/dist/client/tester/tester.html +1 -1
- package/dist/context.js +4 -5
- package/dist/expect-element.js +2 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +46 -28
- package/dist/{locators-CPBpJv8y.js → locators-CVQtUwrj.js} +1 -1
- package/dist/locators.js +1 -1
- package/package.json +8 -8
- package/dist/client/__vitest_browser__/rrweb-snapshot-iZCFA2to.js +0 -4388
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"../../../../node_modules/.pnpm/rrweb-snapshot@2.0.
|
|
3
|
-
"file": "__vitest_browser__/rrweb-snapshot-
|
|
2
|
+
"../../../../node_modules/.pnpm/rrweb-snapshot@2.0.1_patch_hash=9e976b2c55a5c2ed589c41b8f46cc44b6fe6f528ebb4d3780a44b1ca8cbb17a4/node_modules/rrweb-snapshot/dist/rrweb-snapshot.js": {
|
|
3
|
+
"file": "__vitest_browser__/rrweb-snapshot-DkFyu2W8.js",
|
|
4
4
|
"name": "rrweb-snapshot",
|
|
5
|
-
"src": "../../../../node_modules/.pnpm/rrweb-snapshot@2.0.
|
|
5
|
+
"src": "../../../../node_modules/.pnpm/rrweb-snapshot@2.0.1_patch_hash=9e976b2c55a5c2ed589c41b8f46cc44b6fe6f528ebb4d3780a44b1ca8cbb17a4/node_modules/rrweb-snapshot/dist/rrweb-snapshot.js",
|
|
6
6
|
"isDynamicEntry": true
|
|
7
7
|
},
|
|
8
8
|
"_defineProperty-WHpdAQXR.js": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"name": "defineProperty"
|
|
11
11
|
},
|
|
12
12
|
"orchestrator.html": {
|
|
13
|
-
"file": "__vitest_browser__/orchestrator-
|
|
13
|
+
"file": "__vitest_browser__/orchestrator-pKob2Z-i.js",
|
|
14
14
|
"name": "orchestrator",
|
|
15
15
|
"src": "orchestrator.html",
|
|
16
16
|
"isEntry": true,
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
]
|
|
20
20
|
},
|
|
21
21
|
"tester/tester.html": {
|
|
22
|
-
"file": "__vitest_browser__/tester-
|
|
22
|
+
"file": "__vitest_browser__/tester-DdZeFrjo.js",
|
|
23
23
|
"name": "tester",
|
|
24
24
|
"src": "tester/tester.html",
|
|
25
25
|
"isEntry": true,
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"_defineProperty-WHpdAQXR.js"
|
|
28
28
|
],
|
|
29
29
|
"dynamicImports": [
|
|
30
|
-
"../../../../node_modules/.pnpm/rrweb-snapshot@2.0.
|
|
30
|
+
"../../../../node_modules/.pnpm/rrweb-snapshot@2.0.1_patch_hash=9e976b2c55a5c2ed589c41b8f46cc44b6fe6f528ebb4d3780a44b1ca8cbb17a4/node_modules/rrweb-snapshot/dist/rrweb-snapshot.js"
|
|
31
31
|
]
|
|
32
32
|
}
|
|
33
33
|
}
|
package/dist/client/__vitest_browser__/{orchestrator-bDJB3Bid.js → orchestrator-pKob2Z-i.js}
RENAMED
|
@@ -18,6 +18,7 @@ var IframeOrchestrator = class {
|
|
|
18
18
|
_defineProperty(this, "iframes", /* @__PURE__ */ new Map());
|
|
19
19
|
_defineProperty(this, "readyIframes", /* @__PURE__ */ new Set());
|
|
20
20
|
_defineProperty(this, "readyWaiters", /* @__PURE__ */ new Map());
|
|
21
|
+
_defineProperty(this, "messageId", 0);
|
|
21
22
|
_defineProperty(this, "eventTarget", new EventTarget());
|
|
22
23
|
_defineProperty(this, "traces", void 0);
|
|
23
24
|
_defineProperty(this, "loggedIframe", /* @__PURE__ */ new WeakSet());
|
|
@@ -175,20 +176,38 @@ Received URL: ${href || "unknown due to CORS"}\nExpected: ${iframe.src}`)));
|
|
|
175
176
|
const waiter = this.readyWaiters.get(iframeId);
|
|
176
177
|
if (waiter) {
|
|
177
178
|
this.readyWaiters.delete(iframeId);
|
|
178
|
-
waiter();
|
|
179
|
+
waiter.resolve();
|
|
179
180
|
}
|
|
180
181
|
}
|
|
181
182
|
waitForReady(iframeId) {
|
|
182
183
|
if (this.readyIframes.has(iframeId)) return Promise.resolve();
|
|
183
|
-
return new Promise((resolve) => {
|
|
184
|
-
|
|
184
|
+
return new Promise((resolve, reject) => {
|
|
185
|
+
const timeout = getIframeTimeout();
|
|
186
|
+
const timer = setTimeout(() => {
|
|
187
|
+
this.readyWaiters.delete(iframeId);
|
|
188
|
+
reject(/* @__PURE__ */ new Error(`The iframe "${iframeId}" did not become ready within ${timeout}ms. The tester likely failed to initialize, check the browser console for errors.`));
|
|
189
|
+
}, timeout);
|
|
190
|
+
this.readyWaiters.set(iframeId, {
|
|
191
|
+
resolve: () => {
|
|
192
|
+
clearTimeout(timer);
|
|
193
|
+
resolve();
|
|
194
|
+
},
|
|
195
|
+
reject: (error) => {
|
|
196
|
+
clearTimeout(timer);
|
|
197
|
+
reject(error);
|
|
198
|
+
}
|
|
199
|
+
});
|
|
185
200
|
});
|
|
186
201
|
}
|
|
187
202
|
removeIframe(iframeId) {
|
|
188
203
|
const iframe = this.iframes.get(iframeId);
|
|
189
204
|
this.iframes.delete(iframeId);
|
|
190
205
|
this.readyIframes.delete(iframeId);
|
|
191
|
-
this.readyWaiters.
|
|
206
|
+
const waiter = this.readyWaiters.get(iframeId);
|
|
207
|
+
if (waiter) {
|
|
208
|
+
this.readyWaiters.delete(iframeId);
|
|
209
|
+
waiter.reject(/* @__PURE__ */ new Error(`The iframe "${iframeId}" was removed before it became ready.`));
|
|
210
|
+
}
|
|
192
211
|
iframe === null || iframe === void 0 || iframe.remove();
|
|
193
212
|
}
|
|
194
213
|
createWarningMessage(iframeId, location) {
|
|
@@ -275,12 +294,14 @@ Received URL: ${href || "unknown due to CORS"}\nExpected: ${iframe.src}`)));
|
|
|
275
294
|
});
|
|
276
295
|
break;
|
|
277
296
|
}
|
|
278
|
-
default:
|
|
279
|
-
|
|
297
|
+
default: {
|
|
298
|
+
const event = e.data.event;
|
|
299
|
+
if (typeof event === "string" && (event.startsWith("response:") || event.startsWith("ack:"))) break;
|
|
280
300
|
await client.rpc.onUnhandledError({
|
|
281
301
|
name: "Unexpected Event",
|
|
282
302
|
message: `Unexpected event: ${e.data.event}`
|
|
283
303
|
}, "Unexpected Event");
|
|
304
|
+
}
|
|
284
305
|
}
|
|
285
306
|
}
|
|
286
307
|
async sendEventToIframe(event) {
|
|
@@ -292,23 +313,38 @@ Received URL: ${href || "unknown due to CORS"}\nExpected: ${iframe.src}`)));
|
|
|
292
313
|
this.iframeEvents.set(iframe, events);
|
|
293
314
|
}
|
|
294
315
|
events.add(event.event);
|
|
295
|
-
|
|
316
|
+
const messageId = this.messageId++;
|
|
317
|
+
channel.postMessage({
|
|
318
|
+
...event,
|
|
319
|
+
messageId
|
|
320
|
+
});
|
|
296
321
|
return new Promise((resolve, reject) => {
|
|
322
|
+
let ackTimer;
|
|
297
323
|
const cleanupEvents = () => {
|
|
324
|
+
clearTimeout(ackTimer);
|
|
298
325
|
channel.removeEventListener("message", onReceived);
|
|
299
326
|
this.eventTarget.removeEventListener("iframeerror", onError);
|
|
327
|
+
events.delete(event.event);
|
|
300
328
|
};
|
|
329
|
+
const timeout = getIframeTimeout();
|
|
330
|
+
ackTimer = setTimeout(() => {
|
|
331
|
+
cleanupEvents();
|
|
332
|
+
reject(/* @__PURE__ */ new Error(`The iframe "${event.iframeId}" did not acknowledge the "${event.event}" message within ${timeout}ms. The tester might have crashed, been removed, or be blocked by a long synchronous task.`));
|
|
333
|
+
}, timeout);
|
|
301
334
|
function onReceived(e) {
|
|
302
|
-
if (e.data.iframeId
|
|
303
|
-
|
|
335
|
+
if (e.data.iframeId !== event.iframeId || e.data.messageId !== messageId) return;
|
|
336
|
+
if (e.data.event === `ack:${event.event}`) {
|
|
337
|
+
clearTimeout(ackTimer);
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
if (e.data.event === `response:${event.event}`) {
|
|
304
341
|
cleanupEvents();
|
|
305
|
-
|
|
342
|
+
resolve();
|
|
306
343
|
}
|
|
307
344
|
}
|
|
308
345
|
function onError(e) {
|
|
309
|
-
reject(e.detail);
|
|
310
346
|
cleanupEvents();
|
|
311
|
-
|
|
347
|
+
reject(e.detail);
|
|
312
348
|
}
|
|
313
349
|
this.eventTarget.addEventListener("iframeerror", onError);
|
|
314
350
|
channel.addEventListener("message", onReceived);
|
|
@@ -352,5 +388,8 @@ function debug(...args) {
|
|
|
352
388
|
const debug = getConfig().env.VITEST_BROWSER_DEBUG;
|
|
353
389
|
if (debug && debug !== "false") client.rpc.debug(...args.map(String));
|
|
354
390
|
}
|
|
391
|
+
function getIframeTimeout() {
|
|
392
|
+
return Number(getConfig().env.VITEST_BROWSER_IFRAME_TIMEOUT) || 6e4;
|
|
393
|
+
}
|
|
355
394
|
|
|
356
395
|
//#endregion
|