MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / startSampling

Function startSampling

e2e/scenarios/artifact-loading-surface.test.ts:125–148  ·  view source on GitHub ↗
(page: Page)

Source from the content-addressed store, hash-verified

123 * layout that jumps is the same defect wearing a different hat.
124 */
125const startSampling = async (page: Page): Promise<void> => {
126 await page.addInitScript(() => {
127 globalThis.__loadingSamples = [];
128 const sample = () => {
129 const stage = document.querySelector<HTMLElement>(
130 '[data-testid="artifact-shell-container"], [data-slot="artifact-stage-skeleton"]',
131 );
132 const box = stage?.getBoundingClientRect();
133 globalThis.__loadingSamples?.push({
134 text: document.body?.innerText ?? "",
135 stage: box
136 ? {
137 x: Math.round(box.x),
138 y: Math.round(box.y),
139 w: Math.round(box.width),
140 h: Math.round(box.height),
141 }
142 : null,
143 });
144 globalThis.__loadingSampler = requestAnimationFrame(sample);
145 };
146 sample();
147 });
148};
149
150const readSamples = (page: Page): Promise<ReadonlyArray<Sample>> =>
151 page.evaluate(() => globalThis.__loadingSamples ?? []);

Calls 1

sampleFunction · 0.85

Tested by

no test coverage detected