Skip to content

Commit 24443b0

Browse files
committed
chore: add playwright
1 parent 3867af9 commit 24443b0

File tree

4 files changed

+182
-41
lines changed

4 files changed

+182
-41
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,9 @@
33
node_modules
44
.coverage
55
docs/
6+
7+
# Playwright
8+
/test-results/
9+
/playwright-report/
10+
/blob-report/
11+
/playwright/.cache/

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
"test": "vitest",
1212
"test:ui": "vitest --ui",
1313
"test:coverage": "vitest run --coverage",
14+
"e2e": "playwright test",
15+
"e2e:ui": "playwright test --ui",
16+
"e2e:headed": "playwright test --headed",
17+
"e2e:debug": "playwright test --debug",
1418
"build": "tsc -b && vite build",
1519
"lint:eslint": "eslint . --ext ts,tsx --report-unused-disable-directives",
1620
"lint:tsc": "tsc --pretty",
@@ -30,9 +34,11 @@
3034
},
3135
"devDependencies": {
3236
"@eslint/js": "9.33.0",
37+
"@playwright/test": "1.55.0",
3338
"@testing-library/jest-dom": "^6.6.3",
3439
"@testing-library/react": "^16.3.0",
3540
"@testing-library/user-event": "^14.5.2",
41+
"@types/node": "24.3.0",
3642
"@types/react": "^19.1.8",
3743
"@types/react-dom": "^19.1.6",
3844
"@typescript-eslint/eslint-plugin": "^8.35.0",

playwright.config.ts

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
import { defineConfig, devices } from '@playwright/test';
2+
3+
/**
4+
* Read environment variables from file.
5+
* https://github.com/motdotla/dotenv
6+
*/
7+
// import dotenv from 'dotenv';
8+
// import path from 'path';
9+
// dotenv.config({ path: path.resolve(__dirname, '.env') });
10+
11+
/**
12+
* See https://playwright.dev/docs/test-configuration.
13+
*/
14+
export default defineConfig({
15+
testDir: './src/__tests__/repeat/e2e',
16+
/* Run tests in files in parallel */
17+
fullyParallel: true,
18+
/* Fail the build on CI if you accidentally left test.only in the source code. */
19+
forbidOnly: !!process.env.CI,
20+
/* Retry on CI only */
21+
retries: process.env.CI ? 2 : 0,
22+
/* Opt out of parallel tests on CI. */
23+
workers: process.env.CI ? 1 : undefined,
24+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
25+
reporter: 'html',
26+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
27+
use: {
28+
/* Base URL to use in actions like `await page.goto('/')`. */
29+
baseURL: 'http://localhost:5173',
30+
31+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
32+
trace: 'on-first-retry',
33+
},
34+
35+
/* Configure projects for major browsers */
36+
projects: [
37+
{
38+
name: 'setup:repeat',
39+
testMatch: '**/setup/*.ts',
40+
},
41+
42+
{
43+
name: 'chromium',
44+
use: { ...devices['Desktop Chrome'], storageState: 'playwright/.auth/repeat.json' },
45+
dependencies: ['setup:repeat'],
46+
},
47+
48+
{
49+
name: 'firefox',
50+
use: { ...devices['Desktop Firefox'], storageState: 'playwright/.auth/repeat.json' },
51+
dependencies: ['setup:repeat'],
52+
},
53+
54+
{
55+
name: 'webkit',
56+
use: { ...devices['Desktop Safari'], storageState: 'playwright/.auth/repeat.json' },
57+
dependencies: ['setup:repeat'],
58+
},
59+
60+
/* Test against mobile viewports. */
61+
// {
62+
// name: 'Mobile Chrome',
63+
// use: { ...devices['Pixel 5'] },
64+
// },
65+
// {
66+
// name: 'Mobile Safari',
67+
// use: { ...devices['iPhone 12'] },
68+
// },
69+
70+
/* Test against branded browsers. */
71+
// {
72+
// name: 'Microsoft Edge',
73+
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
74+
// },
75+
// {
76+
// name: 'Google Chrome',
77+
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
78+
// },
79+
],
80+
81+
/* Run your local dev server before starting the tests */
82+
webServer: {
83+
command: 'pnpm dev',
84+
url: 'http://localhost:5173',
85+
reuseExistingServer: !process.env.CI,
86+
timeout: 120_000,
87+
},
88+
});

0 commit comments

Comments
 (0)