MCPcopy Index your code
hub / github.com/tinyplex/tinybase / waitForDocShotImages

Function waitForDocShotImages

test/e2e/doc-shots.test.ts:129–153  ·  view source on GitHub ↗
(
  page: Page,
  shot: {waitForImages?: string},
)

Source from the content-addressed store, hash-verified

127};
128
129const waitForDocShotImages = async (
130 page: Page,
131 shot: {waitForImages?: string},
132): Promise<void> => {
133 if (shot.waitForImages == null) {
134 return;
135 }
136 const frame = await getFirstFrame(page);
137 await frame?.evaluate(async (selector) => {
138 const images = [
139 ...document.querySelectorAll<HTMLImageElement>(selector),
140 ].filter(({src}) => src != '');
141 await Promise.all(
142 images.map((image) =>
143 image.complete
144 ? undefined
145 : new Promise<void>((resolve) => {
146 const done = () => resolve();
147 image.addEventListener('load', done, {once: true});
148 image.addEventListener('error', done, {once: true});
149 }),
150 ),
151 );
152 }, shot.waitForImages);
153};
154
155const getClip = async (
156 page: Page,

Callers 1

expectDocShotFunction · 0.85

Calls 2

getFirstFrameFunction · 0.85
addEventListenerMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…