diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 8de42d0..9234270 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -7,13 +7,10 @@ on: workflow_dispatch: jobs: test: - timeout-minutes: 10 + timeout-minutes: 30 runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 - with: - node-version: 18 - uses: pnpm/action-setup@v2 with: version: 8 @@ -21,10 +18,8 @@ jobs: run: pnpm install --frozen-lockfile - name: Build app run: pnpm build - - name: Install Playwright Browsers - run: pnpm exec playwright install --with-deps - name: Run Playwright tests - run: pnpm exec playwright test + run: pnpm test - uses: actions/upload-artifact@v3 if: always() with: diff --git a/compose.test.yaml b/compose.test.yaml new file mode 100644 index 0000000..e691f81 --- /dev/null +++ b/compose.test.yaml @@ -0,0 +1,9 @@ +services: + playwright: + image: mcr.microsoft.com/playwright:v1.39.0-jammy + working_dir: /work + volumes: + - .:/work + network_mode: host + environment: + - CI diff --git a/package.json b/package.json index 87f9458..c2464e3 100644 --- a/package.json +++ b/package.json @@ -10,8 +10,8 @@ "build": "next build", "analyze": "ANALYZE=true next build", "start": "serve out", - "test": "playwright test", - "test:update": "playwright test --update-snapshots", + "test": "docker compose -f compose.test.yaml run --rm playwright npx playwright test", + "test:update": "pnpm test -- --update-snapshots", "test:report": "playwright show-report", "deploy": "firebase deploy --project devtoysweb", "check": "pnpm typecheck && pnpm lint && pnpm format:check", diff --git a/playwright.config.ts b/playwright.config.ts index 3d2389e..e282c80 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -51,7 +51,7 @@ export default defineConfig({ /* Run your local dev server before starting the tests */ webServer: { - command: "pnpm start", + command: "npm run start", url: "http://127.0.0.1:3000", reuseExistingServer: !process.env.CI, }, diff --git a/tests/app/page.spec.ts b/tests/app/page.spec.ts index 61a9c5b..5934f11 100644 --- a/tests/app/page.spec.ts +++ b/tests/app/page.spec.ts @@ -1,10 +1,6 @@ import { expect, test } from "@playwright/test"; -// avoid VRT on CI because of difference between CI and local test env -// we can do VRT on CI if dockerize local test env -if (!process.env.CI) { - test("VRT", async ({ page }) => { - await page.goto("/"); - await expect(page).toHaveScreenshot(); - }); -} +test("VRT", async ({ page }) => { + await page.goto("/"); + await expect(page).toHaveScreenshot(); +}); diff --git a/tests/app/page.spec.ts-snapshots/VRT-1-chromium-darwin.png b/tests/app/page.spec.ts-snapshots/VRT-1-chromium-darwin.png deleted file mode 100644 index 851b93c..0000000 Binary files a/tests/app/page.spec.ts-snapshots/VRT-1-chromium-darwin.png and /dev/null differ diff --git a/tests/app/page.spec.ts-snapshots/VRT-1-chromium-linux.png b/tests/app/page.spec.ts-snapshots/VRT-1-chromium-linux.png new file mode 100644 index 0000000..5b76181 Binary files /dev/null and b/tests/app/page.spec.ts-snapshots/VRT-1-chromium-linux.png differ diff --git a/tests/app/page.spec.ts-snapshots/VRT-1-firefox-darwin.png b/tests/app/page.spec.ts-snapshots/VRT-1-firefox-darwin.png deleted file mode 100644 index 9a5747a..0000000 Binary files a/tests/app/page.spec.ts-snapshots/VRT-1-firefox-darwin.png and /dev/null differ diff --git a/tests/app/page.spec.ts-snapshots/VRT-1-firefox-linux.png b/tests/app/page.spec.ts-snapshots/VRT-1-firefox-linux.png new file mode 100644 index 0000000..7ba991c Binary files /dev/null and b/tests/app/page.spec.ts-snapshots/VRT-1-firefox-linux.png differ diff --git a/tests/app/page.spec.ts-snapshots/VRT-1-webkit-darwin.png b/tests/app/page.spec.ts-snapshots/VRT-1-webkit-darwin.png deleted file mode 100644 index 304c478..0000000 Binary files a/tests/app/page.spec.ts-snapshots/VRT-1-webkit-darwin.png and /dev/null differ diff --git a/tests/app/page.spec.ts-snapshots/VRT-1-webkit-linux.png b/tests/app/page.spec.ts-snapshots/VRT-1-webkit-linux.png new file mode 100644 index 0000000..3770fbe Binary files /dev/null and b/tests/app/page.spec.ts-snapshots/VRT-1-webkit-linux.png differ