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