test: use Docker for playwright tests

This commit is contained in:
rusconn
2023-10-16 00:51:20 +09:00
parent 612613859c
commit 8fadf783b6
11 changed files with 18 additions and 18 deletions

View File

@@ -7,13 +7,10 @@ on:
workflow_dispatch: workflow_dispatch:
jobs: jobs:
test: test:
timeout-minutes: 10 timeout-minutes: 30
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- uses: pnpm/action-setup@v2 - uses: pnpm/action-setup@v2
with: with:
version: 8 version: 8
@@ -21,10 +18,8 @@ jobs:
run: pnpm install --frozen-lockfile run: pnpm install --frozen-lockfile
- name: Build app - name: Build app
run: pnpm build run: pnpm build
- name: Install Playwright Browsers
run: pnpm exec playwright install --with-deps
- name: Run Playwright tests - name: Run Playwright tests
run: pnpm exec playwright test run: pnpm test
- uses: actions/upload-artifact@v3 - uses: actions/upload-artifact@v3
if: always() if: always()
with: with:

9
compose.test.yaml Normal file
View File

@@ -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

View File

@@ -10,8 +10,8 @@
"build": "next build", "build": "next build",
"analyze": "ANALYZE=true next build", "analyze": "ANALYZE=true next build",
"start": "serve out", "start": "serve out",
"test": "playwright test", "test": "docker compose -f compose.test.yaml run --rm playwright npx playwright test",
"test:update": "playwright test --update-snapshots", "test:update": "pnpm test -- --update-snapshots",
"test:report": "playwright show-report", "test:report": "playwright show-report",
"deploy": "firebase deploy --project devtoysweb", "deploy": "firebase deploy --project devtoysweb",
"check": "pnpm typecheck && pnpm lint && pnpm format:check", "check": "pnpm typecheck && pnpm lint && pnpm format:check",

View File

@@ -51,7 +51,7 @@ export default defineConfig({
/* Run your local dev server before starting the tests */ /* Run your local dev server before starting the tests */
webServer: { webServer: {
command: "pnpm start", command: "npm run start",
url: "http://127.0.0.1:3000", url: "http://127.0.0.1:3000",
reuseExistingServer: !process.env.CI, reuseExistingServer: !process.env.CI,
}, },

View File

@@ -1,10 +1,6 @@
import { expect, test } from "@playwright/test"; import { expect, test } from "@playwright/test";
// avoid VRT on CI because of difference between CI and local test env test("VRT", async ({ page }) => {
// we can do VRT on CI if dockerize local test env await page.goto("/");
if (!process.env.CI) { await expect(page).toHaveScreenshot();
test("VRT", async ({ page }) => { });
await page.goto("/");
await expect(page).toHaveScreenshot();
});
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB