diff --git a/e2e/visual.spec.ts b/e2e/visual.spec.ts index f20fd54..9677bca 100644 --- a/e2e/visual.spec.ts +++ b/e2e/visual.spec.ts @@ -1,7 +1,9 @@ import { test, expect } from '@playwright/test'; +import { pages } from "./pages.ts"; -test('example test', async ({ page }) => { - await page.goto('http://localhost:8081/blog/02_compiler_parsing/index.html'); - await expect(page).toHaveScreenshot({ fullPage: true }); -}); - +for (const pageUrl of pages) { + test(`visual regression for ${pageUrl}`, async ({ page }) => { + await page.goto(pageUrl); + await expect(page).toHaveScreenshot({ fullPage: true }); + }); +} diff --git a/functions.bash b/functions.bash index 796171f..f23d297 100644 --- a/functions.bash +++ b/functions.bash @@ -1,3 +1,8 @@ function cleanurls { for result in $(find . -name "result-*"); do; (cd $result; python3 ../chatgpt-fix-root-URLs.py); done; } -function htmls { find -s result-$1 -name "*.html" | sed "s|^result-$1/||"; } +function htmls { find -s result-$1/blog -name "*.html" | sed "s|^result-$1/|http://localhost:8081/|" | awk 'BEGIN { print "export const pages = [" } { printf(" \"%s\",\n", $0); } END { print "]" }'; } function commonhtmls { comm -12 <(htmls $1) <(htmls $2); } +function compare { + commonhtmls $1 $2 > e2e/pages.ts; + # (cd result-$1 && python -m http.server 8081 & SERVER_PID=$! && trap "kill $SERVER_PID" EXIT && sleep 1 && cd .. && npx playwright test); + (cd result-$2 && python -m http.server 8081 & SERVER_PID=$! && trap "kill $SERVER_PID" EXIT && sleep 1 && cd .. && npx playwright test); +} diff --git a/playwright.config.ts b/playwright.config.ts index efd9b88..30bb96d 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -14,13 +14,13 @@ import { defineConfig, devices } from '@playwright/test'; export default defineConfig({ testDir: './e2e', /* Run tests in files in parallel */ - fullyParallel: true, + fullyParallel: false, /* Fail the build on CI if you accidentally left test.only in the source code. */ forbidOnly: !!process.env.CI, /* Retry on CI only */ - retries: process.env.CI ? 2 : 0, + retries: process.env.CI ? 2 : 2, /* Opt out of parallel tests on CI. */ - workers: process.env.CI ? 1 : undefined, + workers: process.env.CI ? 1 : 1, /* Reporter to use. See https://playwright.dev/docs/test-reporters */ reporter: 'html', /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ @@ -34,10 +34,10 @@ export default defineConfig({ /* Configure projects for major browsers */ projects: [ - { - name: 'chromium', - use: { ...devices['Desktop Chrome'] }, - }, + // { + // name: 'chromium', + // use: { ...devices['Desktop Chrome'] }, + // }, { name: 'firefox',