Latest settings

Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
This commit is contained in:
Danila Fedorin 2025-04-12 17:35:36 -07:00
parent 4cd4cf18f0
commit 7028e64fab
3 changed files with 20 additions and 13 deletions

View File

@ -1,7 +1,9 @@
import { test, expect } from '@playwright/test'; import { test, expect } from '@playwright/test';
import { pages } from "./pages.ts";
test('example test', async ({ page }) => { for (const pageUrl of pages) {
await page.goto('http://localhost:8081/blog/02_compiler_parsing/index.html'); test(`visual regression for ${pageUrl}`, async ({ page }) => {
await page.goto(pageUrl);
await expect(page).toHaveScreenshot({ fullPage: true }); await expect(page).toHaveScreenshot({ fullPage: true });
}); });
}

View File

@ -1,3 +1,8 @@
function cleanurls { for result in $(find . -name "result-*"); do; (cd $result; python3 ../chatgpt-fix-root-URLs.py); done; } 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 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);
}

View File

@ -14,13 +14,13 @@ import { defineConfig, devices } from '@playwright/test';
export default defineConfig({ export default defineConfig({
testDir: './e2e', testDir: './e2e',
/* Run tests in files in parallel */ /* 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. */ /* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI, forbidOnly: !!process.env.CI,
/* Retry on CI only */ /* Retry on CI only */
retries: process.env.CI ? 2 : 0, retries: process.env.CI ? 2 : 2,
/* Opt out of parallel tests on CI. */ /* 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 to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html', reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ /* 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 */ /* Configure projects for major browsers */
projects: [ projects: [
{ // {
name: 'chromium', // name: 'chromium',
use: { ...devices['Desktop Chrome'] }, // use: { ...devices['Desktop Chrome'] },
}, // },
{ {
name: 'firefox', name: 'firefox',