MCPcopy Create free account
hub / github.com/CyberAgentHack/web-speed-hackathon-2025 / waitForVideoToLoad

Function waitForVideoToLoad

workspaces/test/src/utils.ts:21–38  ·  view source on GitHub ↗
(videoLocator: Locator)

Source from the content-addressed store, hash-verified

19}
20
21export async function waitForVideoToLoad(videoLocator: Locator): Promise<void> {
22 // メタデータが読み込まれれば、動画のサイズが取得できる
23 await videoLocator.evaluate((video) => {
24 if (!(video instanceof HTMLVideoElement)) {
25 throw new Error('Element is not a video');
26 }
27 return new Promise((resolve) => {
28 if (video.readyState >= 1) {
29 resolve(null);
30 return;
31 }
32
33 video.addEventListener('loadedmetadata', () => {
34 resolve(null);
35 });
36 });
37 });
38}
39
40export async function waitForAllImagesToLoad(locator: Locator, expectedNumberOfImages: number = 1): Promise<void> {
41 const images = locator.locator('img');

Callers 1

full-page.test.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected