(page: Page)
| 124 | * layout that jumps is the same defect wearing a different hat. |
| 125 | */ |
| 126 | const 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 | |
| 151 | const readSamples = (page: Page): Promise<ReadonlyArray<Sample>> => |
| 152 | page.evaluate(() => globalThis.__loadingSamples ?? []); |
no test coverage detected