-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
74 lines (67 loc) · 2.56 KB
/
Copy pathplaywright.config.ts
File metadata and controls
74 lines (67 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import { defineConfig, devices } from '@playwright/test';
/**
* Playwright config — mobile-responsiveness verification.
*
* Scope: this suite lives entirely under `e2e/` and runs in a real browser. It
* does NOT overlap with the Vitest unit suite (which owns `*.test.ts(x)` under
* jsdom). Keep `npm run test` (Vitest) and `npm run test:e2e` (this) separate.
*
* The webServer boots Vite on a FIXED port (strictPort) so the baseURL is
* deterministic; `reuseExistingServer` lets a dev server already running on that
* port be reused locally.
*/
// Port + server command are env-overridable so a run can dodge a port another
// process is holding (E2E_PORT) or test the static production build via preview
// (E2E_PREVIEW=1) instead of the dev server. Defaults are unchanged.
const PORT = Number(process.env.E2E_PORT ?? 5180);
const BASE_URL = `http://localhost:${PORT}`;
const SERVER_CMD = process.env.E2E_PREVIEW
? `npm run preview -- --port ${PORT} --strictPort`
: `npm run dev -- --port ${PORT} --strictPort`;
/** Phone + tablet widths the overhaul targets (320–414 phones, 768 tablet),
* plus a desktop width (1280) as a regression sentinel for the unchanged
* desktop layout. */
const VIEWPORTS = [
{ name: 'w320', width: 320, height: 568 },
{ name: 'w375', width: 375, height: 667 },
{ name: 'w390', width: 390, height: 844 },
{ name: 'w414', width: 414, height: 896 },
{ name: 'w768', width: 768, height: 1024 },
{ name: 'w1280', width: 1280, height: 800 },
] as const;
export default defineConfig({
testDir: './e2e',
testMatch: '**/*.spec.ts',
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 1 : 0,
reporter: [['list'], ['html', { open: 'never' }]],
timeout: 60_000,
expect: { timeout: 10_000 },
use: {
baseURL: BASE_URL,
trace: 'on-first-retry',
// Touch is the whole point — emulate a touch-capable device everywhere.
hasTouch: true,
isMobile: true,
},
projects: VIEWPORTS.map((vp) => ({
name: vp.name,
use: {
...devices['Desktop Chrome'],
viewport: { width: vp.width, height: vp.height },
hasTouch: true,
isMobile: true,
// Phones run at a high device-pixel-ratio (modern iPhones report 3). Emulate
// it for the phone widths so tests exercise the real retina path (and verify
// the MapLibre pixelRatio cap). The 1280 desktop sentinel stays at 1.
deviceScaleFactor: vp.width <= 600 ? 3 : 1,
},
})),
webServer: {
command: SERVER_CMD,
url: BASE_URL,
reuseExistingServer: !process.env.CI,
timeout: 120_000,
},
});