-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaywright.config.js
More file actions
79 lines (71 loc) · 2.4 KB
/
Copy pathplaywright.config.js
File metadata and controls
79 lines (71 loc) · 2.4 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
75
76
77
78
79
import { defineConfig, devices } from '@playwright/test';
import path from 'path';
import { fileURLToPath } from 'url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
/**
* Playwright configuration for Lockout Game E2E tests.
*
* Both the backend and frontend servers are started automatically via the
* `webServer` option — no manual server startup required.
*
* Run: npm run test:e2e
*/
export default defineConfig({
testDir: './e2e',
// Run tests sequentially — full-game tests coordinate across multiple browser
// contexts and must not interfere with each other.
fullyParallel: false,
workers: 1,
// Retry once on CI to handle flakiness from timing-dependent socket events.
retries: process.env.CI ? 1 : 0,
reporter: [
['html', { open: 'never', outputFolder: 'playwright-report' }],
['list'],
],
use: {
baseURL: 'http://localhost:5173',
trace: 'retain-on-failure',
screenshot: 'only-on-failure',
video: 'retain-on-failure',
},
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
],
// Automatically start (and stop) both servers before (and after) the suite.
webServer: [
{
// Flask + SocketIO backend — started via gunicorn with the eventlet worker
// class to match the production setup and avoid the Werkzeug stat-reloader
// conflicting with eventlet's event loop (which causes WebSocket connections
// to stall for minutes when using `python -m backend.app` with debug=True).
command:
'gunicorn --bind 0.0.0.0:5000 --workers 1 --worker-class eventlet --timeout 120 "backend.app:app"',
url: 'http://localhost:5000/health',
reuseExistingServer: !process.env.CI,
timeout: 30_000,
env: {
SECRET_KEY: 'playwright-test-secret',
FRONTEND_URL: 'http://localhost:5173',
ALLOWED_ORIGINS: 'http://localhost:5173',
},
},
{
// React + Vite frontend
command: 'npm run dev',
cwd: path.join(__dirname, 'frontend'),
url: 'http://localhost:5173',
reuseExistingServer: !process.env.CI,
timeout: 30_000,
// Spread process.env first so PATH and other host vars are inherited,
// then override with Vite-specific values.
env: {
...process.env,
VITE_API_URL: 'http://localhost:5000/api',
VITE_SOCKET_URL: 'http://localhost:5000',
},
},
],
});