-
-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
72 lines (66 loc) · 2.16 KB
/
playwright.config.ts
File metadata and controls
72 lines (66 loc) · 2.16 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
import { defineConfig, devices } from "@playwright/test";
/**
* Playwright configuration for visual regression testing.
*
* Tests are run against a locally served build of lecture-python-programming
* to verify theme styling hasn't regressed.
*/
export default defineConfig({
testDir: "./tests/visual",
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: process.env.CI
? [
["html", { open: "never" }],
["json", { outputFile: "playwright-report/results.json" }],
["list"],
]
: [["html", { open: "never" }], ["list"]],
// Shared settings for all projects
use: {
// Base URL for the locally served lecture site
baseURL: process.env.BASE_URL || "http://localhost:8000",
trace: "on-first-retry",
},
// Configure projects for different viewports
projects: [
{
name: "desktop-chrome",
use: {
...devices["Desktop Chrome"],
viewport: { width: 1280, height: 720 },
},
},
{
name: "mobile-chrome",
use: {
...devices["Pixel 5"],
},
},
],
// Snapshot configuration
expect: {
toHaveScreenshot: {
// Allow small pixel differences (anti-aliasing, font rendering)
maxDiffPixelRatio: 0.01,
// Threshold for individual pixel color difference
threshold: 0.2,
},
},
// Use platform-specific snapshot directories via SNAPSHOT_DIR env var
// CI (ubuntu) uses default, tox on macOS sets SNAPSHOT_DIR=macos
// Include project name to separate desktop/mobile snapshots
snapshotPathTemplate: process.env.SNAPSHOT_DIR
? `{testDir}/{testFileDir}/${process.env.SNAPSHOT_DIR}/{projectName}/{arg}{ext}`
: "{testDir}/{testFileDir}/__snapshots__/{projectName}/{arg}{ext}",
// Web server to serve the built lecture site
// Path varies: CI uses _build/html, tox uses lectures/_build/html
webServer: {
command: `python -m http.server 8000 --directory ${process.env.SITE_PATH || "lecture-python-programming/lectures/_build/html"}`,
url: "http://localhost:8000",
reuseExistingServer: !process.env.CI,
timeout: 120 * 1000,
},
});