Skip to content

Commit ef88863

Browse files
committed
Stabilize preview screenshots
1 parent 3fc1024 commit ef88863

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/ci/screenshots.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,20 @@ const endpoints = {
1010
SettingsActivity: '1d3dc3e03047b0c7/settings',
1111
}
1212

13+
async function gotoPage(page: Awaited<ReturnType<BrowserContext['newPage']>>, path: string) {
14+
const url = `${baseUrl}/${path}`
15+
try {
16+
await page.goto(url, { waitUntil: 'networkidle' })
17+
} catch (error) {
18+
if (!(error instanceof Error) || !error.message.includes('ERR_ABORTED')) throw error
19+
await page.goto(url, { waitUntil: 'domcontentloaded' })
20+
}
21+
}
22+
1323
async function takeScreenshots(deviceType: string, context: BrowserContext) {
1424
const page = await context.newPage()
1525
for (const [route, path] of Object.entries(endpoints)) {
16-
await page.goto(`${baseUrl}/${path}`, { waitUntil: 'networkidle' })
26+
await gotoPage(page, path)
1727
await page.waitForTimeout(1500)
1828
await page.screenshot({ path: `${outDir}/${route}-${deviceType}.playwright.png` })
1929
console.log(`${route}-${deviceType}.playwright.png`)

0 commit comments

Comments
 (0)