(label: string, javaScriptEnabled: boolean, outPath: string)
| 72 | const browser = await chromium.launch(); |
| 73 | |
| 74 | const shoot = async (label: string, javaScriptEnabled: boolean, outPath: string): Promise<void> => { |
| 75 | const context = await browser.newContext({ |
| 76 | colorScheme: "dark", |
| 77 | viewport: { width: 1280, height: 800 }, |
| 78 | baseURL: baseUrl, |
| 79 | javaScriptEnabled, |
| 80 | }); |
| 81 | await context.addCookies([{ name: cookieName!, value: cookieValue!, url: baseUrl }]); |
| 82 | const page = await context.newPage(); |
| 83 | // Always wait for the stylesheet to land (networkidle) before shooting: it's |
| 84 | // render-blocking, so a real first paint already has `color-scheme: light |
| 85 | // dark` applied and shiki's light-dark() syntax colors resolve to the dark |
| 86 | // palette. Screenshotting at `commit` (pre-stylesheet) would instead capture |
| 87 | // the light palette — an artifact no user sees. JS stays disabled for the |
| 88 | // SSR shot only to freeze the pre-hydration origin (no client correction), |
| 89 | // not to skip CSS. |
| 90 | await visit(page, "/"); |
| 91 | // The install command is the thing that flashes; screenshot just its block. |
| 92 | const command = page.locator('pre:has-text("add-mcp")').first(); |
| 93 | await command.waitFor({ state: "visible", timeout: 15_000 }); |
| 94 | const text = (await command.innerText()).replace(/\s+/g, " ").trim(); |
| 95 | console.log(`${label}: ${text}`); |
| 96 | await command.screenshot({ path: outPath }); |
| 97 | await context.close(); |
| 98 | }; |
| 99 | |
| 100 | await shoot("ssr (first paint)", false, `${outPrefix}-ssr.png`); |
| 101 | await shoot("hydrated", true, `${outPrefix}-hydrated.png`); |
no test coverage detected