forked from hack-rpi/HackRPI-Website-2025
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
145 lines (123 loc) · 3.76 KB
/
playwright.config.ts
File metadata and controls
145 lines (123 loc) · 3.76 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import { defineConfig, devices } from "@playwright/test";
import path from "path";
/**
* Configuration for Playwright tests optimized for HackRPI website
* @see https://playwright.dev/docs/test-configuration
*/
export default defineConfig({
// Directory where tests are located
testDir: "./e2e",
// Maximum time one test can run - increased for complex registration flows
timeout: 45 * 1000,
// Optimize workers for CI environments
workers: process.env.CI ? (process.env.PLAYWRIGHT_WORKERS ? parseInt(process.env.PLAYWRIGHT_WORKERS) : 1) : undefined,
// Enable this for maximum parallelism
fullyParallel: true,
// Fail the build on CI if you accidentally left test.only in the source code
forbidOnly: !!process.env.CI,
// Retry failed tests in CI to reduce flakiness - hackathon sites often have external dependencies
retries: process.env.CI ? 2 : 0,
// Reporter configuration for detailed test reports
reporter: [["html", { open: "never" }], ["junit", { outputFile: "playwright-results.xml" }], ["list"]],
// Global setup for auth and test data relevant to hackathon
globalSetup: "./e2e/global-setup.ts",
// Use shared context for all tests by default
use: {
// Base URL for all tests
baseURL: "http://localhost:3000",
// Capture screenshots only on failure
screenshot: "only-on-failure",
// Record video only on failure - useful for complex UI interactions
video: "on-first-retry",
// Store traces for debugging flaky tests
trace: "on-first-retry",
// Set viewport size to common desktop size
viewport: { width: 1280, height: 720 },
},
// Testing projects tailored for HackRPI scenarios
projects: [
// Main project for most tests - using Chromium
{
name: "chromium",
use: {
...devices["Desktop Chrome"],
// Allow hackathon registration tests more time
actionTimeout: 15000,
},
testMatch: [/^(?!.*\/(mobile|auth|visual)\/).*\.spec\.ts$/],
},
// Authentication-specific tests
{
name: "authenticated",
use: {
...devices["Desktop Chrome"],
// Storage state with authenticated user
storageState: "./e2e/storage/authenticated.json",
},
testMatch: "**/auth/**/*.spec.ts",
dependencies: ["setup"],
},
// Setup project that runs before auth tests
{
name: "setup",
testMatch: "**/setup/**/*.setup.ts",
},
// Test specifically for mobile experiences (schedule, registration)
{
name: "mobile",
use: {
...devices["Pixel 7"],
},
testMatch: "**/mobile/**/*.spec.ts",
},
// Visual testing for critical components like event cards, schedule display
{
name: "visual",
use: {
...devices["Desktop Chrome"],
screenshot: "on",
},
testMatch: "**/visual/**/*.spec.ts",
},
// For CI, we'll run only critical paths on additional browsers
...(process.env.CI
? [
{
name: "firefox-critical",
use: { ...devices["Desktop Firefox"] },
testMatch: "**/critical/**/*.spec.ts",
},
{
name: "safari-critical",
use: { ...devices["Desktop Safari"] },
testMatch: "**/critical/**/*.spec.ts",
},
]
: [
// Include all browsers for local testing if desired
{
name: "firefox",
use: { ...devices["Desktop Firefox"] },
},
{
name: "webkit",
use: { ...devices["Desktop Safari"] },
},
]),
],
// Faster web server configuration that's optimized for development vs CI
webServer: {
command: process.env.CI ? "npm run build && npm run start" : "npm run dev",
url: "http://localhost:3000",
reuseExistingServer: !process.env.CI,
timeout: 120 * 1000,
stdout: "pipe",
stderr: "pipe",
},
// Folder for test outputs organized by test type
outputDir: "test-results/",
// Expect timeout increased for complex operations like form submissions
expect: {
timeout: 10000,
},
});