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

Function startSampling

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

Source from the content-addressed store, hash-verified

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

Calls 1

sampleFunction · 0.85

Tested by

no test coverage detected