Skip to content

Commit 55afb7f

Browse files
committed
Add Playwright for visual testing and setup git lfs
1 parent beab51d commit 55afb7f

File tree

8 files changed

+149
-3
lines changed

8 files changed

+149
-3
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
spock-website/tests/__screenshots__/**/*.png filter=lfs diff=lfs merge=lfs -text

.github/workflows/verify.yaml

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,57 @@ concurrency:
99
cancel-in-progress: true
1010

1111
jobs:
12-
verify:
12+
build:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- name: Checkout
1616
uses: actions/checkout@v4
17+
18+
- name: Verify LFS files
19+
run: |
20+
git lfs install
21+
git lfs fsck --pointers HEAD
22+
1723
- name: Set up Node
1824
uses: actions/setup-node@v4
1925
with:
2026
node-version: lts/*
2127
cache: 'npm'
28+
2229
- name: Install dependencies
2330
run: npm ci
31+
2432
- name: Build
2533
run: npm run build
34+
2635
- name: Upload artifact
2736
uses: 'actions/upload-artifact@v4'
2837
with:
2938
name: 'gh-pages-preview'
3039
path: './spock-website/dist'
40+
41+
verify:
42+
runs-on: ubuntu-latest
43+
steps:
44+
- name: Checkout
45+
uses: actions/checkout@v4
46+
with:
47+
lfs: true # Download LFS files for screenshots
48+
49+
- name: Set up Node
50+
uses: actions/setup-node@v4
51+
with:
52+
node-version: lts/*
53+
cache: 'npm'
54+
- name: Install dependencies
55+
run: npm ci
56+
57+
- name: Run Playwright Tests
58+
run: npx playwright test
59+
60+
- name: Upload Test Results (optional)
61+
uses: actions/upload-artifact@v4
62+
if: always()
63+
with:
64+
name: playwright-report
65+
path: spock-website/playwright-report/

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
.idea/
22
node_modules/
3+
dist/
4+
playwright-report/
5+
test-results/
36

47
# Logs
58
logs
@@ -10,8 +13,6 @@ yarn-error.log*
1013
pnpm-debug.log*
1114
lerna-debug.log*
1215

13-
node_modules
14-
dist
1516
dist-ssr
1617
*.local
1718

spock-website/package-lock.json

Lines changed: 64 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

spock-website/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"preview": "vite preview"
1010
},
1111
"devDependencies": {
12+
"@playwright/test": "^1.52.0",
1213
"typescript": "~5.7.2",
1314
"vite": "^6.3.1"
1415
},

spock-website/playwright.config.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { defineConfig, devices } from '@playwright/test';
2+
3+
export default defineConfig({
4+
reporter: process.env.CI ? ['github', 'html'] : 'html',
5+
// Configure projects for major browsers.
6+
projects: [
7+
{
8+
name: 'chromium',
9+
use: devices['Desktop Chrome'],
10+
},
11+
{
12+
name: 'firefox',
13+
use: devices['Desktop Firefox'],
14+
},
15+
],
16+
// Single template for all assertions
17+
testDir: 'tests',
18+
snapshotPathTemplate: '{testDir}/__screenshots__{/projectName}/{testFilePath}/{arg}{ext}',
19+
// Run local dev server before starting the tests.
20+
use: {
21+
// Base URL to use in actions like `await page.goto('/')`.
22+
baseURL: 'http://localhost:5173',
23+
24+
// Collect trace when retrying the failed test.
25+
trace: 'on-first-retry',
26+
},
27+
webServer: {
28+
command: 'npm run dev',
29+
url: 'http://localhost:5173',
30+
reuseExistingServer: !process.env.CI,
31+
},
32+
});

spock-website/tests/visual.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
test('visual snapshot', async ({ page }) => {
4+
await page.goto('/?disableaos');
5+
await expect(page).toHaveScreenshot('index.png', { fullPage: true });
6+
});

spock-website/tsconfig.test.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"include": [
4+
"tests/**/*.spec.ts",
5+
],
6+
}

0 commit comments

Comments
 (0)