2025-04-05 21:25:21 -07:00
|
|
|
import { test, expect } from '@playwright/test';
|
2025-04-12 17:35:36 -07:00
|
|
|
import { pages } from "./pages.ts";
|
2025-04-05 21:25:21 -07:00
|
|
|
|
2025-04-12 17:35:36 -07:00
|
|
|
for (const pageUrl of pages) {
|
|
|
|
|
test(`visual regression for ${pageUrl}`, async ({ page }) => {
|
2026-01-18 22:16:02 -08:00
|
|
|
await page.goto(pageUrl, { waitUntil: 'networkidle' });
|
|
|
|
|
|
|
|
|
|
// 1. Ensure all stylesheets are parsed
|
|
|
|
|
await page.waitForFunction(() =>
|
|
|
|
|
Array.from(document.styleSheets).every(
|
|
|
|
|
s => !s.href || s.cssRules !== null
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
await page.evaluate(() => document.fonts.ready);
|
|
|
|
|
|
|
|
|
|
await page.addStyleTag({
|
|
|
|
|
content: `
|
|
|
|
|
*, *::before, *::after {
|
|
|
|
|
animation: none !important;
|
|
|
|
|
transition: none !important;
|
|
|
|
|
caret-color: transparent !important;
|
|
|
|
|
}
|
|
|
|
|
`,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await page.evaluate(() => new Promise(requestAnimationFrame));
|
|
|
|
|
|
2025-04-12 17:35:36 -07:00
|
|
|
await expect(page).toHaveScreenshot({ fullPage: true });
|
|
|
|
|
});
|
|
|
|
|
}
|