-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaywright.visual.config.ts
More file actions
167 lines (142 loc) 路 4.15 KB
/
Copy pathplaywright.visual.config.ts
File metadata and controls
167 lines (142 loc) 路 4.15 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
import { defineConfig, devices } from "@playwright/test";
import { VisualRegressionTracker } from "@visual-regression-tracker/sdk";
/**
* Playwright configuration for visual regression testing
* Separate from E2E tests to focus on visual validation
*/
export default defineConfig({
testDir: "./app/tests/visual",
testMatch: "**/*.visual.{test,spec}.{js,ts,jsx,tsx}",
// Global setup for visual tests
globalSetup: require.resolve("./app/tests/visual/global-setup.ts"),
globalTeardown: require.resolve("./app/tests/visual/global-teardown.ts"),
// Retry visual tests (they can be flaky)
retries: 2,
// Timeout for visual tests (longer due to rendering)
timeout: 30000,
// Parallel execution for visual tests
workers: process.env.CI ? 2 : 4,
// Reporter configuration
reporter: [
["html", { outputFolder: "./playwright-visual-report" }],
["json", { outputFile: "./playwright-visual-results.json" }],
["junit", { outputFile: "./playwright-visual-results.xml" }],
],
// Use configured browsers for visual testing
use: {
// Base URL for the application
baseURL: process.env.E2E_BASE_URL || "http://localhost:3000",
// Take screenshot on failure
screenshot: "only-on-failure",
// Record video on failure
video: "retain-on-failure",
// Trace on failure
trace: "retain-on-failure",
// Ignore HTTPS errors for local testing
ignoreHTTPSErrors: true,
// Wait for network idle before considering page loaded
waitUntil: "networkidle",
// Timeout for actions
actionTimeout: 10000,
// Disable animations for consistent screenshots
launchOptions: {
args: [
"--disable-web-security",
"--disable-features=VizDisplayCompositor",
"--disable-background-timer-throttling",
"--disable-backgrounding-occluded-windows",
"--disable-renderer-backgrounding",
"--disable-features=TranslateUI",
"--disable-ipc-flooding-protection",
"--disable-accelerated-2d-canvas",
"--no-first-run",
"--no-default-browser-check",
"--disable-default-apps",
"--disable-popup-blocking",
],
},
} as any,
// Projects for different browsers and viewports
projects: [
{
name: "chrome-desktop",
use: {
...devices["Desktop Chrome"],
viewport: { width: 1280, height: 720 },
},
},
{
name: "chrome-mobile",
use: {
...devices["Pixel 5"],
viewport: { width: 393, height: 851 },
},
},
{
name: "chrome-tablet",
use: {
...devices["iPad Pro"],
viewport: { width: 1024, height: 1366 },
},
},
{
name: "firefox-desktop",
use: {
...devices["Desktop Firefox"],
viewport: { width: 1280, height: 720 },
},
},
{
name: "safari-desktop",
use: {
...devices["Desktop Safari"],
viewport: { width: 1280, height: 720 },
},
},
// Dark mode variants
{
name: "chrome-desktop-dark",
use: {
...devices["Desktop Chrome"],
viewport: { width: 1280, height: 720 },
colorScheme: "dark",
reducedMotion: "reduce",
} as any,
},
// High contrast mode
{
name: "chrome-desktop-high-contrast",
use: {
...devices["Desktop Chrome"],
viewport: { width: 1280, height: 720 },
forcedColors: "active",
} as any,
},
// RTL layout
{
name: "chrome-desktop-rtl",
use: {
...devices["Desktop Chrome"],
viewport: { width: 1280, height: 720 },
locale: "ar-SA",
},
},
],
// Web server for local testing
webServer: {
command:
"VISUAL_TESTING=true NEXT_PUBLIC_VISUAL_TESTING=true API_RATE_LIMIT=100000 AUTH_RATE_LIMIT=100000 yarn --cwd app dev",
port: 3000,
reuseExistingServer: !process.env.CI,
timeout: 120000,
},
// Output directory for test artifacts
outputDir: "./playwright-visual-results",
// Environment variables
env: {
VISUAL_TESTING: "true",
SCREENSHOT_DIR: "./screenshots",
BASELINE_DIR: "./screenshots/baseline",
DIFF_DIR: "./screenshots/diff",
},
} as any);