Skip to content

Commit e37dc6f

Browse files
committed
Add playwright tests
1 parent e654e7d commit e37dc6f

File tree

8 files changed

+351
-24
lines changed

8 files changed

+351
-24
lines changed

.github/workflows/main.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,24 @@ jobs:
1212
- uses: actions/checkout@v4
1313
- uses: actions/setup-node@v4
1414
with:
15-
node-version: '20'
15+
node-version: lts/*
1616
cache: 'npm'
1717
- run: npm ci
1818
- run: npm run lint
1919
- run: npm run check
2020
- run: npm run test
21+
22+
e2e_test:
23+
runs-on: ubuntu-latest
24+
25+
steps:
26+
- uses: actions/checkout@v4
27+
- uses: actions/setup-node@v4
28+
with:
29+
node-version: lts/*
30+
cache: 'npm'
31+
- run: npm ci
32+
- run: npm run build
33+
- name: Install Playwright Browsers
34+
run: npx playwright install --with-deps
35+
- run: npx playwright test

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
node_modules
22

33
dist
4+
/test-results/
5+
/playwright-report/
6+
/blob-report/
7+
/playwright/.cache/

package-lock.json

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

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"format": "prettier . --ignore-path .gitignore --write",
99
"postformat": "eslint . --fix",
1010
"test": "npm run check && vitest",
11+
"e2e": "playwright test --project chromium",
1112
"check": "tsc --noEmit",
1213
"dev": "vite",
1314
"build": "vite build",
@@ -19,6 +20,8 @@
1920
},
2021
"devDependencies": {
2122
"@eslint/js": "^9.8.0",
23+
"@playwright/test": "^1.46.0",
24+
"@types/node": "^22.1.0",
2225
"@typescript/lib-dom": "npm:@types/web@^0.0.151",
2326
"@vitejs/plugin-legacy": "^5.4.1",
2427
"eslint": "^9.8.0",

playwright.config.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { defineConfig, devices } from '@playwright/test';
2+
3+
const webServer = false;
4+
5+
/**
6+
* See https://playwright.dev/docs/test-configuration.
7+
*/
8+
export default defineConfig({
9+
testDir: './tests/e2e',
10+
/* Run tests in files in parallel */
11+
fullyParallel: true,
12+
/* Fail the build on CI if you accidentally left test.only in the source code. */
13+
forbidOnly: !!process.env.CI,
14+
/* Retry on CI only */
15+
retries: process.env.CI ? 2 : 0,
16+
use: {
17+
baseURL: webServer ? 'http://127.0.0.1:4173' : 'https://maskable.app/',
18+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
19+
trace: 'on-first-retry',
20+
},
21+
22+
/* Configure projects for major browsers */
23+
projects: [
24+
{
25+
name: 'chromium',
26+
use: { ...devices['Desktop Chrome'] },
27+
},
28+
29+
{
30+
name: 'firefox',
31+
use: { ...devices['Desktop Firefox'] },
32+
},
33+
34+
{
35+
name: 'webkit',
36+
use: { ...devices['Desktop Safari'] },
37+
},
38+
39+
/* Test against mobile viewports. */
40+
{
41+
name: 'Mobile Chrome',
42+
use: { ...devices['Pixel 5'] },
43+
},
44+
{
45+
name: 'Mobile Safari',
46+
use: { ...devices['iPhone 12'] },
47+
},
48+
],
49+
50+
/* Run your local dev server before starting the tests */
51+
webServer: webServer
52+
? {
53+
command: 'npm run preview',
54+
url: 'http://127.0.0.1:4173',
55+
reuseExistingServer: !process.env.CI,
56+
}
57+
: undefined,
58+
});

0 commit comments

Comments
 (0)