Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .claude-plugin/marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"plugins": [
{
"name": "visualci",
"version": "0.1.53",
"version": "0.1.54",
"description": "Visual regression and snapshot review for PDFs, screenshots, JSON, HTML and text: VisualCI's MCP server and its skills for each CI provider and test tool.",
"author": { "name": "DocSpring", "url": "https://visualci.com" },
"homepage": "https://visualci.com/docs/skills/",
Expand Down
2 changes: 1 addition & 1 deletion .claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "visualci",
"version": "0.1.53",
"version": "0.1.54",
"description": "Visual regression and snapshot review for PDFs, screenshots, JSON, HTML and text: VisualCI's MCP server and its skills for each CI provider and test tool.",
"author": { "name": "DocSpring", "url": "https://visualci.com" },
"homepage": "https://visualci.com/docs/skills/",
Expand Down
2 changes: 1 addition & 1 deletion .cursor-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "visualci",
"displayName": "VisualCI",
"version": "0.1.53",
"version": "0.1.54",
"description": "Visual regression and snapshot review for PDFs, screenshots, JSON, HTML and text: VisualCI's MCP server and its skills for each CI provider and test tool.",
"author": {
"name": "DocSpring"
Expand Down
30 changes: 29 additions & 1 deletion frontend/content/docs/screenshots/deterministic.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ as a change somebody has to look at. Fix these in the tests, once, rather than a
| Lazy-loaded images | Wait for every image to finish loading |
| Viewport, scrollbars, pixel ratio | Fix the viewport size, hide scrollbars, use a device pixel ratio of 1 |
| Text cursor, hover, focus | Hide the caret, and move the mouse away |
| Anti-aliased edges and icons a shade off | Launch Chromium with software raster on one thread ([flags](#steady-rasterising)) |
| Scroll position | Scroll once the page has stopped changing, never while it still lays out |

What's left after this (anti-aliasing that differs slightly between runs) is what a
What's left after this (anti-aliasing that still differs slightly between runs, as between two machines) is what a
[threshold](/docs/screenshots/#thresholds) is for. A threshold can't fix a clock or an animation: those change far
more pixels than anti-aliasing does.

Expand Down Expand Up @@ -123,6 +124,33 @@ purpose: a screenshot from a Retina laptop is twice the size of one from CI). Hi
operating systems and appear only when content overflows. Hide the text cursor, and move the mouse away from
anything with a hover state.

### Steady rasterising

Chromium rasterises on the GPU, in tiles and on several threads, so the anti-aliased edges of rounded corners, borders
and small SVG icons can come out a shade different from one run to the next on the same machine: a handful of pixels,
one colour step off, with nothing else changed. Launch it with software rasterising on one thread, one colour profile
and greyscale text, and those edges come out the same every run:

```ts
// playwright.config.ts
use: {
launchOptions: {
args: [
'--disable-gpu',
'--force-color-profile=srgb',
'--disable-partial-raster',
'--disable-skia-runtime-opts',
'--disable-lcd-text',
'--font-render-hinting=none',
'--num-raster-threads=1',
],
},
},
```

The same flags work with `chromium.launch({ args })` and Puppeteer's `launch({ args })`. Switching them on changes
every screenshot slightly once (greyscale text instead of subpixel text), so approve that build as the new baseline.

### Scroll position

A test that scrolls an element into view before the screenshot gets a different scroll position on each run when the
Expand Down
2 changes: 1 addition & 1 deletion frontend/content/docs/screenshots/playwright.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ visualci upload --platform webkit-linux --threshold 0.1 screenshots/webkit
visualci build finalize
```

Use this instead of `toHaveScreenshot`: the baselines live on VisualCI, a change waits for review instead of failing the test, and no PNGs are committed. Hide content that changes on every run (times, avatars) with Playwright's `mask` option, or wait for animations to finish, before the screenshot. [Deterministic screenshots](/docs/screenshots/deterministic/#playwright) has a fixture that pins the clock, randomness and network.
Use this instead of `toHaveScreenshot`: the baselines live on VisualCI, a change waits for review instead of failing the test, and no PNGs are committed. Hide content that changes on every run (times, avatars) with Playwright's `mask` option, or wait for animations to finish, before the screenshot. [Deterministic screenshots](/docs/screenshots/deterministic/#playwright) has a fixture that pins the clock, randomness and network. Launch Chromium with the [steady rasterising flags](/docs/screenshots/deterministic/#steady-rasterising) too, or rounded corners and icons can differ by a shade between runs.

Run the tests in CI's browsers, not on a laptop: see [Platforms](/docs/screenshots/#platforms) and [Local runs](/docs/local-runs/).
2 changes: 1 addition & 1 deletion gemini-extension.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "visualci",
"version": "0.1.53",
"version": "0.1.54",
"description": "Visual regression and snapshot review for PDFs, screenshots, JSON, HTML and text: VisualCI's MCP server and its skills for each CI provider and test tool.",
"mcpServers": {
"visualci": {
Expand Down
13 changes: 2 additions & 11 deletions scripts/screenshots/capture.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { dirname, join } from 'node:path'
import { chromium } from 'playwright'

import { EMAIL, NOW, pages } from './pages.mjs'
import { STEADY_RASTER } from './raster.mjs'

/** VisualCI's production gallery, as frontend/src/components/GalleryImage.tsx names it. */
const GALLERY = 'https://app.visualci.com/g/docspring/visualci'
Expand Down Expand Up @@ -100,19 +101,9 @@ async function unstick(page) {

async function main() {
const opts = args()
// Software rasterising on one thread, one colour profile and greyscale text: with the GPU and partial raster, small SVG
// icons came out a few pixels different from run to run.
const browser = await chromium.launch({
...(process.env.CHROME_PATH ? { executablePath: process.env.CHROME_PATH } : {}),
args: [
'--disable-gpu',
'--force-color-profile=srgb',
'--disable-partial-raster',
'--disable-skia-runtime-opts',
'--disable-lcd-text',
'--font-render-hinting=none',
'--num-raster-threads=1',
],
args: STEADY_RASTER,
})
const contexts = new Map()
const missing = new Set()
Expand Down
3 changes: 2 additions & 1 deletion scripts/screenshots/checks.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
import { chromium } from 'playwright'
import { EMAIL, pages } from './pages.mjs'
import { checkLightbox } from './lightbox.mjs'
import { STEADY_RASTER } from './raster.mjs'

const arg = (name, fallback) => {
const i = process.argv.indexOf(name)
return i > 0 ? process.argv[i + 1] : fallback
}
const BASE = arg('--base-url', 'http://127.0.0.1:5151')

const browser = await chromium.launch()
const browser = await chromium.launch({ args: STEADY_RASTER })
try {
await checkLightbox(browser, BASE)

Expand Down
3 changes: 2 additions & 1 deletion scripts/screenshots/journeys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { createHash, randomBytes } from 'node:crypto'
import { mkdir } from 'node:fs/promises'
import { createServer } from 'node:http'
import { chromium, request } from 'playwright'
import { STEADY_RASTER } from './raster.mjs'

const arg = (name, fallback) => {
const i = process.argv.indexOf(`--${name}`)
Expand All @@ -21,7 +22,7 @@ const MCP = 'https://mcp.visualci.test'
const NO_MOTION = '*, *::before, *::after { animation: none !important; transition: none !important; caret-color: transparent !important; }'

await mkdir(out, { recursive: true })
const browser = await chromium.launch()
const browser = await chromium.launch({ args: STEADY_RASTER })
const failures = []

/** One journey in a fresh browser (no cookies), its steps' screenshots named `<journey>/<nn>-<step>`. */
Expand Down
3 changes: 2 additions & 1 deletion scripts/screenshots/lightbox.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// image hasn't loaded yet, the way a slow connection does.
import { chromium } from 'playwright'
import { pathToFileURL } from 'node:url'
import { STEADY_RASTER } from './raster.mjs'

// A 1×1 PNG: the check reads which URL each image shows, not its pixels.
const PNG = Buffer.from(
Expand Down Expand Up @@ -95,7 +96,7 @@ export async function checkLightbox(browser, base) {
if (import.meta.url === pathToFileURL(process.argv[1]).href) {
const i = process.argv.indexOf('--base-url')
const base = i > 0 ? process.argv[i + 1] : 'http://127.0.0.1:5151'
const browser = await chromium.launch()
const browser = await chromium.launch({ args: STEADY_RASTER })
try {
await checkLightbox(browser, base)
} catch (e) {
Expand Down
12 changes: 12 additions & 0 deletions scripts/screenshots/raster.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Chromium flags for screenshots that come out the same every run: software rasterising on one thread, one colour
// profile and greyscale text. With the GPU and partial raster, small SVG icons and rounded corners' anti-aliased edges
// came out a shade different from run to run (4 Dec 2026: 28 pixels on the site header's button in a journey).
export const STEADY_RASTER = [
'--disable-gpu',
'--force-color-profile=srgb',
'--disable-partial-raster',
'--disable-skia-runtime-opts',
'--disable-lcd-text',
'--font-render-hinting=none',
'--num-raster-threads=1',
]
30 changes: 29 additions & 1 deletion skills/visualci-deterministic/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ as a change somebody has to look at. Fix these in the tests, once, rather than a
| Lazy-loaded images | Wait for every image to finish loading |
| Viewport, scrollbars, pixel ratio | Fix the viewport size, hide scrollbars, use a device pixel ratio of 1 |
| Text cursor, hover, focus | Hide the caret, and move the mouse away |
| Anti-aliased edges and icons a shade off | Launch Chromium with software raster on one thread ([flags](#steady-rasterising)) |
| Scroll position | Scroll once the page has stopped changing, never while it still lays out |

What's left after this (anti-aliasing that differs slightly between runs) is what a
What's left after this (anti-aliasing that still differs slightly between runs, as between two machines) is what a
[threshold](https://visualci.com/docs/screenshots.md#thresholds) is for. A threshold can't fix a clock or an animation: those change far
more pixels than anti-aliasing does.

Expand Down Expand Up @@ -128,6 +129,33 @@ purpose: a screenshot from a Retina laptop is twice the size of one from CI). Hi
operating systems and appear only when content overflows. Hide the text cursor, and move the mouse away from
anything with a hover state.

### Steady rasterising

Chromium rasterises on the GPU, in tiles and on several threads, so the anti-aliased edges of rounded corners, borders
and small SVG icons can come out a shade different from one run to the next on the same machine: a handful of pixels,
one colour step off, with nothing else changed. Launch it with software rasterising on one thread, one colour profile
and greyscale text, and those edges come out the same every run:

```ts
// playwright.config.ts
use: {
launchOptions: {
args: [
'--disable-gpu',
'--force-color-profile=srgb',
'--disable-partial-raster',
'--disable-skia-runtime-opts',
'--disable-lcd-text',
'--font-render-hinting=none',
'--num-raster-threads=1',
],
},
},
```

The same flags work with `chromium.launch({ args })` and Puppeteer's `launch({ args })`. Switching them on changes
every screenshot slightly once (greyscale text instead of subpixel text), so approve that build as the new baseline.

### Scroll position

A test that scrolls an element into view before the screenshot gets a different scroll position on each run when the
Expand Down
2 changes: 1 addition & 1 deletion skills/visualci-playwright/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ visualci upload --platform webkit-linux --threshold 0.1 screenshots/webkit
visualci build finalize
```

Use this instead of `toHaveScreenshot`: the baselines live on VisualCI, a change waits for review instead of failing the test, and no PNGs are committed. Hide content that changes on every run (times, avatars) with Playwright's `mask` option, or wait for animations to finish, before the screenshot. [Deterministic screenshots](https://visualci.com/docs/screenshots/deterministic.md#playwright) has a fixture that pins the clock, randomness and network.
Use this instead of `toHaveScreenshot`: the baselines live on VisualCI, a change waits for review instead of failing the test, and no PNGs are committed. Hide content that changes on every run (times, avatars) with Playwright's `mask` option, or wait for animations to finish, before the screenshot. [Deterministic screenshots](https://visualci.com/docs/screenshots/deterministic.md#playwright) has a fixture that pins the clock, randomness and network. Launch Chromium with the [steady rasterising flags](https://visualci.com/docs/screenshots/deterministic.md#steady-rasterising) too, or rounded corners and icons can differ by a shade between runs.

Run the tests in CI's browsers, not on a laptop: see [Platforms](https://visualci.com/docs/screenshots.md#platforms) and [Local runs](https://visualci.com/docs/local-runs.md).

Expand Down
Loading