mirror of
https://github.com/ershisan99/DevToysWeb.git
synced 2025-12-16 20:49:23 +00:00
test: use Docker for playwright tests
This commit is contained in:
9
.github/workflows/playwright.yml
vendored
9
.github/workflows/playwright.yml
vendored
@@ -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
9
compose.test.yaml
Normal 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
|
||||||
@@ -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",
|
||||||
|
|||||||
@@ -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,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -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 |
BIN
tests/app/page.spec.ts-snapshots/VRT-1-chromium-linux.png
Normal file
BIN
tests/app/page.spec.ts-snapshots/VRT-1-chromium-linux.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 61 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 90 KiB |
BIN
tests/app/page.spec.ts-snapshots/VRT-1-firefox-linux.png
Normal file
BIN
tests/app/page.spec.ts-snapshots/VRT-1-firefox-linux.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 87 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 79 KiB |
BIN
tests/app/page.spec.ts-snapshots/VRT-1-webkit-linux.png
Normal file
BIN
tests/app/page.spec.ts-snapshots/VRT-1-webkit-linux.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 56 KiB |
Reference in New Issue
Block a user