-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
130 lines (111 loc) · 3.23 KB
/
Copy pathplaywright.config.ts
File metadata and controls
130 lines (111 loc) · 3.23 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import { defineConfig, devices } from '@playwright/test';
/**
* Playwright configuration for FreedomTalk E2E and API testing
* @see https://playwright.dev/docs/test-configuration
*/
export default defineConfig({
// Test directory
testDir: './tests',
// Run tests in parallel (but not fullyParallel to avoid rate limiting issues)
fullyParallel: false,
// Fail build on CI if you accidentally left test.only in source code
forbidOnly: !!process.env.CI,
// Retry on CI only
retries: process.env.CI ? 2 : 0,
// Parallel workers (limited on CI and locally to avoid rate limiting)
workers: process.env.CI ? 1 : 2,
// Reporter configuration
reporter: [
['html', { outputFolder: 'test-results/html' }],
['json', { outputFile: 'test-results/results.json' }],
['list'],
],
// Global test settings
use: {
// Base URL for tests
baseURL: process.env.E2E_BASE_URL || 'http://localhost:3000',
// Collect trace on failure
trace: 'on-first-retry',
// Screenshot on failure
screenshot: 'only-on-failure',
// Video on failure
video: 'retain-on-failure',
// Action timeout
actionTimeout: 10000,
// Navigation timeout
navigationTimeout: 30000,
// Extra HTTP headers for all requests
extraHTTPHeaders: {
// Add a header to identify test requests (can be used to skip rate limiting)
'X-Test-Request': 'true',
},
},
// Configure projects for major browsers
projects: [
{
name: 'api',
testMatch: /api\/.*\.spec\.ts/,
use: {
baseURL: process.env.API_BASE_URL || 'http://localhost:3001',
},
},
{
name: 'e2e-chromium',
testMatch: /e2e\/.*\.spec\.ts/,
use: {
...devices['Desktop Chrome'],
viewport: { width: 1280, height: 720 },
},
dependencies: ['api'],
},
// Firefox only on main branch (CI)
...(process.env.CI && process.env.GITHUB_REF === 'refs/heads/main'
? [
{
name: 'e2e-firefox',
testMatch: /e2e\/.*\.spec\.ts/,
use: {
...devices['Desktop Firefox'],
viewport: { width: 1280, height: 720 },
},
dependencies: ['api'],
},
]
: []),
],
// Global setup and teardown
globalSetup: './tests/setup/global-setup.ts',
globalTeardown: './tests/setup/global-teardown.ts',
// Web server for E2E tests
webServer: process.env.CI
? undefined
: [
{
command: 'SKIP_RATE_LIMIT=true npm run dev --workspace=@freedomtalk/api',
port: 3001,
timeout: 120000,
// Don't reuse existing server to ensure rate limiting is disabled
reuseExistingServer: false,
env: {
// High rate limit for tests
RATE_LIMIT_MAX: '10000',
// Skip route-level rate limits
SKIP_RATE_LIMIT: 'true',
},
},
{
command: 'npm run dev --workspace=@freedomtalk/web',
port: 3000,
timeout: 120000,
reuseExistingServer: !process.env.CI,
},
],
// Test timeout
timeout: 30000,
// Expect timeout
expect: {
timeout: 5000,
},
// Output directory
outputDir: 'test-results/artifacts',
});