-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvisual-regression.config.ts
More file actions
101 lines (85 loc) · 2.28 KB
/
visual-regression.config.ts
File metadata and controls
101 lines (85 loc) · 2.28 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
import { defineConfig, devices } from '@playwright/test';
/**
* Visual Regression Testing Configuration
*
* This configuration sets up Playwright for visual regression testing,
* capturing screenshots and comparing them against baseline images.
*/
export default defineConfig({
testDir: './frontend/__tests__/visual',
// Timeout for each test
timeout: 30 * 1000,
// Test configuration
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
// Reporter configuration
reporter: [
['html', { outputFolder: 'visual-regression-report' }],
['json', { outputFile: 'visual-regression-results.json' }],
['list'],
],
// Shared settings for all projects
use: {
// Base URL for tests
baseURL: process.env.BASE_URL || 'http://localhost:3000',
// Screenshot configuration
screenshot: 'only-on-failure',
// Video configuration
video: 'retain-on-failure',
// Trace configuration
trace: 'on-first-retry',
// Viewport size
viewport: { width: 1280, height: 720 },
},
// Configure projects for different browsers and viewports
projects: [
{
name: 'chromium-desktop',
use: { ...devices['Desktop Chrome'] },
},
{
name: 'firefox-desktop',
use: { ...devices['Desktop Firefox'] },
},
{
name: 'webkit-desktop',
use: { ...devices['Desktop Safari'] },
},
{
name: 'mobile-chrome',
use: { ...devices['Pixel 5'] },
},
{
name: 'mobile-safari',
use: { ...devices['iPhone 12'] },
},
{
name: 'tablet',
use: { ...devices['iPad Pro'] },
},
],
// Web server configuration
webServer: {
command: 'npm run dev',
url: 'http://localhost:3000',
reuseExistingServer: !process.env.CI,
timeout: 120 * 1000,
},
// Visual comparison settings
expect: {
toHaveScreenshot: {
// Maximum pixel difference threshold
maxDiffPixels: 100,
// Maximum pixel ratio difference
maxDiffPixelRatio: 0.01,
// Threshold for pixel comparison (0-1)
threshold: 0.2,
// Animation handling
animations: 'disabled',
// CSS media type
caret: 'hide',
},
},
});