diff --git a/README.md b/README.md index 61448a0..3c24649 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,8 @@ only the reference has (`band -24`) are missing at y=196. With those rows cut ou matches exactly (`aligned 100.00%`). The missing rows are the "Pricing" nav link, which exists only on the reference (`-`). Open `renderdiff-out/about.1440.c1.png` to see it. -**Without `--threshold`, a diff still exits 0**, so read the summary. +**Any difference exits 1.** `--threshold <0..1>` relaxes that to scores below it +(`--threshold 0` never fails on a difference). Read the summary either way. ### For coding agents @@ -96,12 +97,14 @@ renderdiff [options] | `--left ` | Left origin, instead of the first positional one. Giving both is an error. | | `--right ` | Right origin, instead of the second positional one. | | `--width ` | Viewport width; repeatable. Replaces the defaults. | -| `--threshold <0..1>` | Exit non-zero if any comparison scores below this. | +| `--threshold <0..1>` | Exit 1 only if a comparison scores below this, instead of on any difference. `0` never fails on one. | | `--out ` | Output directory, wiped at the start of a run. Default `./renderdiff-out`. A directory holding files renderdiff didn't write is refused. | | `--concurrency ` | Parallel workers. Default half the CPU cores, between 2 and 8. Lower it when one side is someone's live site. | | `--config ` | Config file. Default: `renderdiff.config.{ts,mts,js,mjs}` in cwd. | | `--selector ` | Compare the one element this Playwright selector matches, on both sides, instead of the whole page. Applies to every route, over the config's per-route `selector`. | | `--left-selector `, `--right-selector ` | That side's selector, over `--selector`. One without the other side (or `--selector`) is an error. | +| `--mask ` | Paint this Playwright selector over on both sides, on every route; repeatable. Added to the config's masks and listed in the report as coverage given up. | +| `--mask-media` | Mask every `iframe`, `video` and `.vjs-text-track-display` (video.js text tracks) on every route, as config `maskMedia: true` does. | | `--storage-state ` | Start both sides with this Playwright storage state (cookies, localStorage), e.g. signed in. Relative to cwd. Over the config's `storageState`. | | `--left-storage-state `, `--right-storage-state ` | That side's storage state, over `--storage-state`. One side alone is fine. | | `--accept ` | Record this run's differences as accepted, with a reason. See **Accepted differences and reruns**. | @@ -121,8 +124,8 @@ range rather than on a boundary, so a layout switch never flaps between runs. | Exit | Meaning | | --- | --- | -| `0` | No route errored and none scored below `--threshold`. Without one, a diff still exits 0. | -| `1` | A route scored below `--threshold`. Wins over `3` when both happen. | +| `0` | No route errored and no shot differs (with `--threshold`: none scored below it). Accepted differences don't count; nor do unstable pixels or a failed asset alone, which still get their own row. | +| `1` | A shot differs, or with `--threshold` scored below it. Wins over `3` when both happen. A difference that can't be accepted (unstable pixels beside it, a width change, a height change whose rows don't align) exits 1 even on the `--accept` run. | | `2` | Bad arguments, bad config, or an origin that isn't responding. | | `3` | A route errored, so it went unmeasured, or the run crashed (e.g. no Chromium). | @@ -149,7 +152,7 @@ screenshots and text) out of git too. Details: [docs/scoping.md](https://github. ## Config file Flags cover a one-off run. A `renderdiff.config.{ts,mts,js,mjs}` in the working directory -covers a repo you diff repeatedly, and expresses what flags can't: **masks** for content +covers a repo you diff repeatedly, and expresses what flags can't: **per-route masks** for content that legitimately drifts, extra selectors to hide, extra URLs to block, `before` hooks. ```ts @@ -213,7 +216,7 @@ renderdiff http://localhost:3000 https://example.com / /about --rerun-failed `--accept ""` writes every difference the run saw to `renderdiff.accepted.json` (next to the config, or in cwd); commit it. Later, a shot whose every difference matches an entry is -listed on an `accepted:` line and counts neither as differing nor toward `--threshold`; +listed on an `accepted:` line and counts neither as differing nor toward the exit code; anything new on the same page still shows. `--rerun-failed` reruns only what the last run in `--out` didn't find clean or accepted and merges it back; it exits 2 if the run differs from the previous one. Matching rules, what can still hide, and stale entries: @@ -287,6 +290,7 @@ Everything lands in the out dir (`./renderdiff-out` by default): "compared": 1, "errors": 1, "mean": 0.9714, "worst": { "url": "/about", "width": 1440, "score": 0.9714 }, "belowThreshold": 0, // accepted shots aside + "differing": 1, // shots with any differing pixel, accepted ones aside "accepted": 0, // shots whose every difference was accepted "stale": [] // accepted entries the run measured but didn't see } diff --git a/action.yml b/action.yml index 4c8d4a4..02f5f0c 100644 --- a/action.yml +++ b/action.yml @@ -22,7 +22,7 @@ inputs: description: Viewport widths separated by spaces or commas. Default renderdiff's five. default: "" threshold: - description: Fail when any comparison scores below this (0..1). Without it only errors fail the job. + description: Fail only when a comparison scores below this (0..1). Without it any difference fails the job; 0 never fails on one. default: "" concurrency: description: Parallel workers, which is also the most loads production sees at once. @@ -45,7 +45,7 @@ inputs: outputs: exit-code: - description: renderdiff's exit code. 0 pass, 1 below threshold, 2 bad input or origin down, 3 a route errored. + description: renderdiff's exit code. 0 pass, 1 a difference (or below threshold), 2 bad input or origin down, 3 a route errored. value: ${{ steps.run.outputs.exit-code }} results: description: Path to results.json. @@ -143,7 +143,7 @@ runs: case $code in 0) verdict="✅ No visual change" ;; - 1) verdict="❌ Below threshold" ;; + 1) verdict="❌ Visual change" ;; 2) verdict="⚠️ Bad input or an origin is down" ;; *) verdict="⚠️ A route errored or the run crashed" ;; esac diff --git a/docs/accepted.md b/docs/accepted.md index 4b158c1..3b6524a 100644 --- a/docs/accepted.md +++ b/docs/accepted.md @@ -15,7 +15,7 @@ the reason. Scope it the way you scope any run: pass only the routes and `--widt Commit the file; it is one entry per line, so its diff reads as what was accepted. A shot whose every difference matches an accepted one is `accepted`: it is listed on an -`accepted:` line like `clean:`, doesn't count as differing or toward `--threshold`, and has +`accepted:` line like `clean:`, doesn't count as differing or toward the exit code, and has `"accepted": true` in `results.json` and a badge in the report. Anything else on the page still shows: a row with some changes accepted says `1 accepted`, and its `dom` line skips them. A shot with unstable pixels is never accepted, since part of it went unmeasured. diff --git a/docs/github-action.md b/docs/github-action.md index 35f9701..750c92f 100644 --- a/docs/github-action.md +++ b/docs/github-action.md @@ -25,7 +25,7 @@ exits non-zero. | `routes` | Separated by spaces or newlines; pairs (`/pricing::/plans`) work. Optional when the config lists routes. | | `config` | Config file path. Default: `renderdiff.config.{ts,mts,js,mjs}` in the workspace. | | `widths` | Spaces or commas. Default renderdiff's five. | -| `threshold` | Fail below this score. Without it, only errors (exit 2 or 3) fail the job. | +| `threshold` | Fail only below this score. Without it, any difference fails the job (exit 1); `"0"` never fails on one. | | `concurrency` | Parallel workers, which is also the most page loads production sees at once. Default 2 on a hosted runner. | | `storage-state` | Contents of a Playwright storage-state JSON, from a secret. Written to a 0600 file in the runner's temp dir and deleted when renderdiff exits. | | `accept` | Record this run's differences as accepted, with this reason. See below. | @@ -37,7 +37,7 @@ To run the action twice in one job, give each run its own `out` and `artifact-na matrix, put the matrix value in `artifact-name`. The action sets up Node 24, which later steps in the job then use. -Outputs: `exit-code` (0 pass, 1 below threshold, 2 bad input or an origin down, 3 a route +Outputs: `exit-code` (0 pass, 1 a difference or below `threshold`, 2 bad input or an origin down, 3 a route errored) and `results` (the path to `results.json`). A Vercel preview behind Deployment Protection answers the runner with its login page: a @@ -92,7 +92,8 @@ The action waits for `left` to answer, so the server can still be starting. ### Dependency upgrades from Renovate or Dependabot -A dependency bump should change nothing, so fail on any difference: +A dependency bump should change nothing. That's the default without `threshold`: any +difference fails. ```yaml if: github.actor == 'renovate[bot]' || github.actor == 'dependabot[bot]' @@ -101,7 +102,6 @@ A dependency bump should change nothing, so fail on any difference: with: left: http://localhost:3000 right: https://example.com - threshold: "1" ``` ## Accepted differences: accept in CI diff --git a/docs/how-it-works.md b/docs/how-it-works.md index 8ece5f2..abb3f8a 100644 --- a/docs/how-it-works.md +++ b/docs/how-it-works.md @@ -63,8 +63,8 @@ honestly. This is what renderdiff does to make sure of that. wrapped (Chrome repeats the top of the page; recent headless Chromium does not), so taller pages, and element shots taller than that, are captured as tiles through CDP and stitched back together. Masks are painted onto the final image from each element's bounding box, - so they apply the same way on both paths. Past 40,000px it errors — that's a broken - layout, not a page. + so they apply the same way on both paths. Past 57.6 million pixels (40,000px tall at + 1440px wide, about 150,000px at 375px) it errors — that's a broken layout, not a page. Every run's report ends with a "What was neutralized" section listing the actual block patterns, mask reasons and pinned settings in effect, so the report can't drift from the diff --git a/renderdiff.config.example.ts b/renderdiff.config.example.ts index 241eac4..d12be20 100644 --- a/renderdiff.config.example.ts +++ b/renderdiff.config.example.ts @@ -92,6 +92,7 @@ export default { // // Each needs exactly one of `selector` (a Playwright selector) or `locate`. Without // `urlPath` it applies to every route; on a pair it matches either side's path. + // `maskMedia: true` (or --mask-media) adds one for iframes, video and video.js text tracks. masks: [ { // Baked in at build time from a nightly job, so a local tree and a production diff --git a/skills/renderdiff/SKILL.md b/skills/renderdiff/SKILL.md index b51dec5..cc2f7fd 100644 --- a/skills/renderdiff/SKILL.md +++ b/skills/renderdiff/SKILL.md @@ -1,6 +1,6 @@ --- name: renderdiff -description: Visual-parity check for website migrations. Use when a framework migration, CSS or design-system refactor, template rewrite, CMS move or dependency/build upgrade should not change how pages look, to prove it by screenshot-diffing a local build against production (or any reference) across viewport widths. Also for "did I break the layout", visual regression checks, pixel diffs of two URLs, or running the renderdiff CLI. +description: Visual-parity check for website migrations. Use when a framework migration, CSS or design-system refactor, template rewrite, CMS move or dependency/build upgrade should not change how pages look, to prove it by screenshot-diffing your change against a local build of the base (or production, or any reference) across viewport widths. Also for "did I break the layout", visual regression checks, pixel diffs of two URLs, or running the renderdiff CLI. allowed-tools: Bash(npx renderdiff:*), Bash(npx renderdiff@latest:*), Bash(renderdiff:*), Read --- @@ -13,20 +13,25 @@ npx renderdiff@latest http://localhost:3000 https://example.com /about --width 1 Left (first origin) = your change; right (second) = the reference. `+` means only/more in your change, `-` only/more in the reference. First run: `npx playwright install chromium`. Flags: `--help`. Moved page: `/old::/new`. One component: `--selector`. Click-gated state: -a config `before` hook. Signed in: `--storage-state auth.json`. When each is +a config `before` hook. Signed in: `--storage-state auth.json`. Per-load noise: `--mask `, `--mask-media`. When each is legitimate: [reference.md](reference.md). ## Loop -1. **Baseline first.** Before changing code, run the unmodified build against the reference - with `--accept "differs before the migration"`: what already differs is recorded, not - yours. Accept only what you looked at, never to get green. -2. Both origins up, with the same content and data. `--dry-run` shows the URL pairs. - Upgrading a dependency or build? The cleanest reference is the pre-upgrade commit in a - `git worktree` on another port: same data, fonts and CDN, so every diff is yours. Serve - a production build: dev overlays and debug bars exist only on your side (Next's and - Astro's are hidden; others go in `hideSelectors`). Routes: one per template or layout, - from the sitemap or router; skip search results, pagination and admin. +1. **Reference: the base, built locally.** When the base can be built, it is the default + reference: the base commit in a `git worktree`, a production build of it on another + port as right, your change as left, both up with the same content. Same data, fonts and CDN, so every diff is yours. + Production as right is a secondary check afterwards: it adds deploy drift, one-sided + third-party content and CSP errors. Serve production builds on both sides: dev overlays + exist only on one side (Next's and Astro's are hidden; others go in `hideSelectors`). + Routes: one per template or layout, from the sitemap or router; skip search results, + pagination and admin. `--dry-run` shows the URL pairs. +2. **Baseline first.** Before changing code, run the base against the reference. Against + the base build that is base vs base, so whatever differs varies per load: mask it + (`--mask-media` for iframes, video and video.js text tracks; `--mask ` or a config + mask with a `reason` for the rest), then rerun until the baseline is clean. Against + production, `--accept "differs before the change"` what is stable drift. Mask or accept + only what you looked at, never to get green. 3. One route, one width. A row: score, `h±N`/`w±N` height/width delta, `band`, `aligned`, `N reg`, `unstable Npx` (moving pixels, unmeasured), `text`. 4. `failed` first: a stylesheet or font one side didn't load explains the whole row; fix @@ -45,8 +50,8 @@ legitimate: [reference.md](reference.md). `--cache-right`. For a multi-width row, open the widest and narrowest crop. `accepted:` routes are known; a row saying `1 accepted` still has something new. -Exit: 0 nothing below `--threshold` (**without it, a diff still exits 0**) · 1 below -threshold · 2 bad args/config/origin down · 3 a route errored (unmeasured) or crash. +Exit: 0 no differing pixels, or all accepted (unstable pixels or a failed asset alone still +exit 0: read their rows) · 1 a difference (with `--threshold`: below it), even on `--accept` for one it can't accept (unstable pixels, width change, unaligned height change) · 2 bad args/config/origin down · 3 a route errored (unmeasured) or crash. 1 wins over 3. All clean? Confirm both sides actually rendered. **Before you mask, lower the threshold, drop a route or skip widths,** read @@ -56,7 +61,7 @@ reference.md's Rationalizations. 1. **Numbers**: the `renderdiff:` line and each differing row. 2. **What you saw**: per route and width, element and property ("/pricing @1440: `.cta` margin-left 24px→16px"). -3. **Not verified**: errors, skipped widths, masks, unopened regions, unlisted routes, baseline drift. +3. **Not verified**: errors, skipped widths, masks, unopened regions, unlisted routes, baseline drift and its reference (base build or production). 4. **Call**: parity, regression, or expected change, and why. A score without looking is not a verdict: 99.6% can be a missing nav link. diff --git a/skills/renderdiff/reference.md b/skills/renderdiff/reference.md index 982888c..f16efc4 100644 --- a/skills/renderdiff/reference.md +++ b/skills/renderdiff/reference.md @@ -41,9 +41,9 @@ Report colouring (`--open`, for a human): green above 99.5%, amber to 97%, red b | "It's probably just fonts / antialiasing." | "Probably" is exactly what the crop resolves. Look. | | "`dom` says margin, done." | It's a computed value. Confirm the source rule changed on purpose, and still open the crop when the region is large or `dom` names nothing. | | "The crops looked fine, done." | There are at most three: bands, then the largest regions. Check the region count, any `clipped` crop in results.json, and open the diff PNG for the rest and for any height delta: padding is never cropped. | -| "Masking the header gets this to 100%." | Every mask is coverage surrendered. Mask only content *proven* to vary per load (clocks, star counts, rotating quotes), with a `reason`, which the report prints verbatim. | +| "Masking the header gets this to 100%." | Every mask is coverage surrendered. Mask only content *proven* to vary per load (clocks, star counts, rotating quotes), with a `reason`, which the report prints verbatim. Differing base vs base is that proof; `--mask-media` still gives up every iframe and video. | | "I'll `--accept` it so the run is green." | Accept only differences you opened and that exist before your change (or are intended), with a reason that says which. | -| "I'll lower `--threshold` until it passes." | Threshold is a CI gate, not a dial for reaching green. | +| "I'll lower `--threshold` until it passes." | `--threshold` relaxes the exit code; the difference is still there. It's a CI gate, not a dial for reaching green. | | "That route errors, I'll drop it from the list." | Shrinking the route list shrinks what you verified. Fix it, or say it's unverified. | | "One width is enough." | Migrations break at one width and not others. That's why there are five defaults. | | "A `before` hook that hides that element on the left gets this clean." | That hook is a mask with no `reason` in the report. A hook brings both sides to the same *state* (opens the menu, dismisses a modal both show, logs in); it never edits one side to match the other. | @@ -56,8 +56,9 @@ px), band, their `elements` (`selector`, `side`, each side's box, `changed`, `te at, `[]` when nothing was named), full text diff, image path and crop (`kind`, each side's box with `h` 0 at an insertion point, `layout` `stacked` = left on top or `side` = left on the left, `scale`, `clipped`), `selector` (`{ left, right }` or null), one result per line, so `grep '"url":"/about"'` pulls a route. -Paths are relative to the out dir. `summary` has `compared`, `errors`, `mean`, `worst` and -`belowThreshold`; `meta` records origins, widths, threshold, the pinned clock, block +Paths are relative to the out dir. `summary` has `compared`, `errors`, `mean`, `worst`, +`belowThreshold` and `differing` (unaccepted shots with any differing pixel: without +`--threshold`, any exits 1); `meta` records origins, widths, threshold, the pinned clock, block patterns, hidden selectors, mask reasons, the browser (`chromium`, or `chrome` when it fell back to the system Chrome), each side's storage state file name, and `rightReplayedFrom` (with `--cache-right`, when the replayed recording was made; also on each replayed result). `hook: true` marks a @@ -85,7 +86,9 @@ export default { A mask takes exactly one of `selector` or `locate: (page) => Locator`; without `urlPath` it applies to every route, and on a pair it matches either side's path and paints both. A plain -`export default {}` needs no import; a type import from "renderdiff" is for editor types only. [`renderdiff.config.example.ts`](https://github.com/tmashara/renderdiff/blob/main/renderdiff.config.example.ts) +`export default {}` needs no import; a type import from "renderdiff" is for editor types only. Without a config, `--mask ` (repeatable) adds a mask on every +route, after the config's; `--mask-media` (config `maskMedia: true`) adds one for +`iframe, video, .vjs-text-track-display`. Both are listed in the report like any mask. [`renderdiff.config.example.ts`](https://github.com/tmashara/renderdiff/blob/main/renderdiff.config.example.ts) annotates every field. Two rules for `hideSelectors`: match the element **exactly** (consent scripts also stamp @@ -95,6 +98,9 @@ cookie script ran wedges the renderer). ## Gotchas +- **Reference choice:** base build vs change build, both local, is the default. Production as + the reference mixes in deploy drift, one-sided embeds (job boards, ads) and CSP blocks: use + it as a second pass, and say in the verdict which reference you used. - **stdout is compact when piped** (what an agent sees). `--progress` prints a line per shot instead; `--no-progress` forces the summary on a terminal. - **Accepted differences** (`--accept ""`) go to `renderdiff.accepted.json` next to the diff --git a/src/capture.ts b/src/capture.ts index 8f19ec6..b309061 100644 --- a/src/capture.ts +++ b/src/capture.ts @@ -34,10 +34,12 @@ const MAX_CAPTURE_HEIGHT = 16_384; const TILE_HEIGHT = 16_000; /** - * Sanity ceiling. Past this a page is far likelier a broken/runaway layout than a real - * one, and we would rather error than stitch a >100MB image. Named in the throw. + * Sanity ceiling on the shot's area, so a narrow page may be taller than a wide one; never + * under 40,000px tall, the old height ceiling, so a wide width loses nothing. Past + * this a page is far likelier a broken/runaway layout than a real one, and we would rather + * error than stitch a >200MB image. Named in the throw. */ -const MAX_PAGE_HEIGHT = 40_000; +const MAX_PAGE_AREA = 1440 * 40_000; /** Requests still open per page, when the last one opened or closed, and stylesheets that failed. */ const network = new WeakMap; last: number; failed: Set }>(); @@ -120,6 +122,7 @@ export async function capture( now: number, ): Promise { await page.setViewportSize({ width, height: 900 }); + const maxHeight = Math.max(40_000, Math.floor(MAX_PAGE_AREA / width)); await page.clock.setSystemTime(now); // Here, not on framenavigated, which a pushState during hydration fires too. network.get(page)!.failed.clear(); @@ -163,7 +166,7 @@ export async function capture( Array.from(document.images).map((img) => img.decode().catch(() => {})), ); await Promise.race([decoded, new Promise((r) => setTimeout(r, 5_000))]); - }, MAX_PAGE_HEIGHT); + }, maxHeight); // fonts.ready also resolves when a face fails, so the failures are read off it below. const fonts = await page.evaluate(async () => { await Promise.race([document.fonts.ready, new Promise((r) => setTimeout(r, 5_000))]); @@ -231,9 +234,10 @@ export async function capture( .map((line) => line.replace(/\s+/g, " ").trim()) .filter(Boolean); const blank = pageText < 200 && !media ? `height=${scrollHeight}, text=${pageText} chars` : null; - if (scrollHeight > MAX_PAGE_HEIGHT) { + if (scrollHeight > maxHeight) { throw new Error( - `page is ${scrollHeight}px tall, past the ${MAX_PAGE_HEIGHT}px sanity ceiling ` + + `page is ${scrollHeight}px tall at ${width}px wide, past the ${maxHeight}px sanity ceiling ` + + `for that width (${MAX_PAGE_AREA.toLocaleString("en-US")} pixels) ` + `at ${url} — likely a broken layout, not a real page`, ); } diff --git a/src/cli.ts b/src/cli.ts index c7d5765..16fe9f0 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -89,6 +89,7 @@ function parseArgs(argv: string[]): Args { else if (v === "--no-progress") a.progress = false; else if (v === "--rerun-failed") a.rerunFailed = true; else if (v === "--cache-right") a.cacheRight = true; + else if (v === "--mask-media") a.maskMedia = true; else if (v === "--accept") { a.accept = next().trim(); if (!a.accept) throw new Error("--accept needs a reason"); @@ -96,7 +97,11 @@ function parseArgs(argv: string[]): Args { else if (v === "--right") a.right = next(); else if (v === "--out") a.outDir = next(); else if (v === "--config") a.config = next(); - else if (v === "--selector" || v === "--left-selector" || v === "--right-selector") { + else if (v === "--mask") { + const s = next().trim(); + if (!s) throw new Error("--mask needs a value"); + (a.masks ??= []).push(s); + } else if (v === "--selector" || v === "--left-selector" || v === "--right-selector") { const s = next(); if (!s) throw new Error(`${v} needs a value`); sel[v === "--selector" ? "both" : v === "--left-selector" ? "left" : "right"] = s; @@ -180,21 +185,24 @@ const HELP = ` the config, or in cwd); later runs report them as accepted, and anything new still shows. --rerun-failed reruns only what the previous run in --out didn't find clean or accepted. - Writes report.html, results.json and crops of each change to --out. Exits 1 if a - route falls below --threshold, 3 if one errored (unmeasured) or the run crashed, 2 on - bad arguments, bad config or an origin that is down. A diff without --threshold exits 0. + Writes report.html, results.json and crops of each change to --out. Exits 1 if any + shot differs (with --threshold, only if one scores below it; --threshold 0 never fails + on a diff), 3 if a route errored (unmeasured) or the run crashed, 2 on bad arguments, + bad config or an origin that is down. Options --left Left origin, instead of the first positional one. --right Right origin, instead of the second positional one. --width Viewport width; repeatable. Replaces the defaults. - --threshold <0..1> Fail if any comparison scores below this. + --threshold <0..1> Fail only if a comparison scores below this, not on any diff. --out Output directory (default: ./renderdiff-out) --concurrency Parallel workers (default: half the cores, 2–8) --config Config file. Default: renderdiff.config.{ts,mts,js,mjs} in cwd. --selector Compare one element (a Playwright selector) on both sides. --left-selector , --right-selector That side's selector, over --selector. + --mask Paint this selector over on both sides, every route; repeatable. + --mask-media Mask iframe, video and .vjs-text-track-display on every route. --storage-state Start both sides with this storage state JSON. Never commit it. --left-storage-state , --right-storage-state @@ -215,7 +223,7 @@ const HELP = ` Default widths: 1440, 1152, 896, 704, 375 - Masks, hidden selectors, blocked URLs and route lists go in a config file; CLI flags + Per-route masks, hidden selectors, blocked URLs and route lists go in a config file; CLI flags win over it. See https://github.com/tmashara/renderdiff#readme `; diff --git a/src/config.ts b/src/config.ts index 57a4ab1..676d3f0 100644 --- a/src/config.ts +++ b/src/config.ts @@ -225,6 +225,12 @@ export type Mask = { | { /** The escape hatch for what a selector can't say. */ locate: (page: Page) => Locator } ); +/** The `maskMedia` / `--mask-media` preset: embeds and players that differ per load. */ +export const MEDIA_MASK: Mask = { + selector: "iframe, video, .vjs-text-track-display", + reason: "iframes, video and video.js text tracks (--mask-media)", +}; + /** The shape a `renderdiff.config.*` file default-exports. Every field is optional. */ export interface RenderdiffConfig { /** Left origin, e.g. `http://localhost:3000`. A trailing slash is stripped. */ @@ -242,7 +248,7 @@ export interface RenderdiffConfig { storageState?: string | { left?: string; right?: string }; /** Viewport widths. Replaces {@link DEFAULT_WIDTHS} outright. */ widths?: number[]; - /** Fail the run if any comparison scores below this, 0..1. */ + /** Fail only when a comparison scores below this (0..1), instead of on any diff. */ threshold?: number; /** Where to write screenshots and `report.html`. Relative paths resolve from cwd. */ outDir?: string; @@ -256,6 +262,8 @@ export interface RenderdiffConfig { extraCss?: string; /** Per-route regions painted over on both sides. */ masks?: Mask[]; + /** Mask every `iframe`, `video` and video.js text track on every route. */ + maskMedia?: boolean; } /** A fully merged config. Everything the run needs, nothing optional. */ @@ -469,6 +477,7 @@ function validate(c: Record, file: string) { } }); } + if (c.maskMedia !== undefined && typeof c.maskMedia !== "boolean") bad("maskMedia", "a boolean"); } /** CLI-supplied values. `undefined` means "not passed", so the config file wins. */ @@ -481,6 +490,9 @@ export interface CliOverrides { concurrency?: number; /** Per side, from --storage-state / --left-storage-state / --right-storage-state. */ storageState?: { left?: string; right?: string }; + /** From --mask, appended to the config's masks. */ + masks?: string[]; + maskMedia?: boolean; } /** Merge built-in defaults, the config file, and CLI flags into one resolved config. */ @@ -517,9 +529,13 @@ export function resolveConfig(file: RenderdiffConfig, cli: CliOverrides): Resolv hideSelectors, neutralizeCss: STILL_CSS + `${hideSelectors.join(",")}{display:none!important}\n` + (file.extraCss ?? ""), - masks: (file.masks ?? []).map((m) => - m.urlPath === undefined ? m : { ...m, urlPath: normalize(m.urlPath) }, - ), + masks: [ + ...(file.masks ?? []).map((m) => + m.urlPath === undefined ? m : { ...m, urlPath: normalize(m.urlPath) }, + ), + ...(cli.masks ?? []).map((selector) => ({ selector, reason: `${selector} (--mask)` })), + ...(cli.maskMedia || file.maskMedia ? [MEDIA_MASK] : []), + ], storageState: { left: storageFile(cli.storageState?.left ?? fileState?.left), right: storageFile(cli.storageState?.right ?? fileState?.right), diff --git a/src/report.ts b/src/report.ts index a5c0d0c..ae867f3 100644 --- a/src/report.ts +++ b/src/report.ts @@ -108,6 +108,8 @@ export interface Summary { worst: { url: string; width: number; score: number } | null; /** Comparisons under `meta.threshold`, accepted ones aside; 0 when no threshold was set. */ belowThreshold: number; + /** Comparisons with any differing pixel, accepted ones aside. Without a threshold, any exits 1. */ + differing: number; /** Comparisons whose every difference was accepted. */ accepted: number; /** Accepted differences for a measured route and width that weren't seen: prune them. */ @@ -153,6 +155,7 @@ export function writeResults( meta.threshold === null ? 0 : compared.filter((r) => !r.accepted && r.score < meta.threshold!).length, + differing: open.filter((r) => r.diffPixels > 0).length, accepted: compared.filter((r) => r.accepted).length, stale, }, diff --git a/src/run.ts b/src/run.ts index a166abf..6cb7506 100644 --- a/src/run.ts +++ b/src/run.ts @@ -504,13 +504,16 @@ export async function run({ spawn(opener, [reportPath], { detached: true, stdio: "ignore" }).unref(); } - // A measured failure outranks an unmeasured route, so an error can't hide a threshold failure. + // A measured failure outranks an unmeasured route, so an error can't hide a diff. const below = results.filter( (r) => - r.status === "compared" && !r.accepted && cfg.threshold !== null && r.score < cfg.threshold, + r.status === "compared" && + !r.accepted && + (cfg.threshold === null ? r.diffPixels > 0 : r.score < cfg.threshold), ); if (below.length) { - console.error(`\n✗ ${below.length} route(s) below ${pct(cfg.threshold!)}.`); + const what = cfg.threshold === null ? "differ" : `below ${pct(cfg.threshold)}`; + console.error(`\n✗ ${below.length} route(s) ${what}.`); } return below.length ? 1 : results.some((r) => r.status === "error") ? 3 : 0; } diff --git a/tests/fixtures/pages/README.md b/tests/fixtures/pages/README.md index bedc325..b47039e 100644 --- a/tests/fixtures/pages/README.md +++ b/tests/fixtures/pages/README.md @@ -18,7 +18,7 @@ Three groups: alignment (`taller`, `nav`, and `shifted`, which has no band), the text diff (`nav`) and the elements each change names (`margin`, `color`, `nav`). - **Guard rails** — `blank`, `tall`, `animated`, `lazy`, `lazy-deep`, `lazy-js`, `consent`, - `drifting`, `tracker`, `clock`, `ticker`, `unsettled`, `sprite`, `short`, `tall-region`, `reorder`, `stripe`, `frameset`, `menu`, `signed-in`, `fixed`, `inserted`, `labelled`, `broken-asset`. + `drifting`, `tracker`, `clock`, `ticker`, `unsettled`, `sprite`, `short`, `tall-region`, `reorder`, `stripe`, `frameset`, `menu`, `signed-in`, `fixed`, `inserted`, `labelled`, `broken-asset`, `media`, `long`. One per defence in `src/capture.ts` / `src/config.ts`. ## Authoring rules diff --git a/tests/fixtures/pages/long/left.html b/tests/fixtures/pages/long/left.html new file mode 100644 index 0000000..1c060f5 --- /dev/null +++ b/tests/fixtures/pages/long/left.html @@ -0,0 +1,22 @@ + + + + +Layout parity + + + + +
+

Long page guard rail

+

A legitimately long page, like a changelog at a phone width. The sanity ceiling bounds the stitched image's area, not its height, so this page is compared at 375px and refused at 1440px, where the same height is four times the pixels.

+
+ + diff --git a/tests/fixtures/pages/long/right.html b/tests/fixtures/pages/long/right.html new file mode 100644 index 0000000..1c060f5 --- /dev/null +++ b/tests/fixtures/pages/long/right.html @@ -0,0 +1,22 @@ + + + + +Layout parity + + + + +
+

Long page guard rail

+

A legitimately long page, like a changelog at a phone width. The sanity ceiling bounds the stitched image's area, not its height, so this page is compared at 375px and refused at 1440px, where the same height is four times the pixels.

+
+ + diff --git a/tests/fixtures/pages/media/left.html b/tests/fixtures/pages/media/left.html new file mode 100644 index 0000000..7a7ee07 --- /dev/null +++ b/tests/fixtures/pages/media/left.html @@ -0,0 +1,24 @@ + + + + +Layout parity + + + + +
+

Media guard rail

+

An iframe, a video and a video.js text track, each different on the two sides. Every one of them is third-party or per-load content on a real site, which is why the preset exists.

+ + +
First caption
+
+ + diff --git a/tests/fixtures/pages/media/right.html b/tests/fixtures/pages/media/right.html new file mode 100644 index 0000000..f1b2c0b --- /dev/null +++ b/tests/fixtures/pages/media/right.html @@ -0,0 +1,24 @@ + + + + +Layout parity + + + + +
+

Media guard rail

+

An iframe, a video and a video.js text track, each different on the two sides. Every one of them is third-party or per-load content on a real site, which is why the preset exists.

+ + +
Second caption
+
+ + diff --git a/tests/fixtures/pages/tall/page.ts b/tests/fixtures/pages/tall/page.ts index e5bae83..1a73c80 100644 --- a/tests/fixtures/pages/tall/page.ts +++ b/tests/fixtures/pages/tall/page.ts @@ -3,7 +3,7 @@ * * Chromium silently truncates a single screenshot past 16,384px, so `capture()` drops to raw * CDP and stitches vertical tiles for anything taller. This page is exactly 18,000px, which - * is past that cap and well under the 40,000px sanity ceiling, so it lands on the tiled path + * is past that cap and well under the sanity ceiling (40,000px at 1440), so it lands on the tiled path * and needs two tiles (16,000 + 2,000). * * The height is exact by construction — 100 blocks of exactly 180px, no margins, no page diff --git a/tests/helpers/corpus.ts b/tests/helpers/corpus.ts index 30fbbb4..3452b4c 100644 --- a/tests/helpers/corpus.ts +++ b/tests/helpers/corpus.ts @@ -49,6 +49,8 @@ export const GUARDRAILS = [ "inserted", "labelled", "broken-asset", + "media", + "long", ] as const; export const ALL: string[] = [...EQUIVALENCE, ...CONTROLS, ...GUARDRAILS]; diff --git a/tests/unit/cli-args.test.ts b/tests/unit/cli-args.test.ts index 0b47aef..447b335 100644 --- a/tests/unit/cli-args.test.ts +++ b/tests/unit/cli-args.test.ts @@ -56,6 +56,8 @@ describe("help and version", () => { "--right-storage-state", "--accept", "--rerun-failed", + "--mask", + "--mask-media", ]) { assert.ok(r.stdout.includes(flag), `--help does not mention ${flag}`); } @@ -120,6 +122,18 @@ describe("flag validation", () => { test("a negative number is not mistaken for a value", () => rejects(["/a", "--left", L, "--right", R, "--width", "-5"], "--width needs a value")); + test("--mask needs a value", async () => { + await rejects(["/a", "--left", L, "--right", R, "--dry-run", "--mask"], "--mask needs a value"); + await rejects( + ["/a", "--left", L, "--right", R, "--dry-run", "--mask="], + "--mask needs a value", + ); + await rejects( + ["/a", "--left", L, "--right", R, "--dry-run", "--mask", " "], + "--mask needs a value", + ); + }); + test("--width rejects non-numbers", () => rejects( ["/a", "--left", L, "--right", R, "--width", "wide"], diff --git a/tests/unit/config-load.test.ts b/tests/unit/config-load.test.ts index 7fe0f98..15b8517 100644 --- a/tests/unit/config-load.test.ts +++ b/tests/unit/config-load.test.ts @@ -170,6 +170,7 @@ describe("validation", () => { /two routes both read as \/a; they have different before hooks — merge them into one route/, ], ['{ routes: [{ left: "/a", before: {} }] }', /`routes\[0\]\.before` must be a function/], + ['{ maskMedia: "yes" }', /`maskMedia` must be a boolean/], ["{ storageState: 1 }", /`storageState` must be a non-empty path/], [ '{ storageState: { left: "a.json", center: "b.json" } }', diff --git a/tests/visual/accepted.test.ts b/tests/visual/accepted.test.ts index 1149119..873fdc2 100644 --- a/tests/visual/accepted.test.ts +++ b/tests/visual/accepted.test.ts @@ -87,7 +87,10 @@ describe("accepted differences", () => { const res = results(run.outDir); assert.equal(result(res, "/color", 1440).accepted, true); assert.equal(result(res, "/color", 1440).regions[0]!.accepted, "known before the move"); - assert.deepEqual([res.summary.accepted, res.summary.belowThreshold], [2, 0]); + assert.deepEqual( + [res.summary.accepted, res.summary.belowThreshold, res.summary.differing], + [2, 0, 0], + ); const report = parseReport(run.report()!); assert.equal(card(report, "/nav", 1440).accepted, "known before the move"); assert.equal(card(report, "/", 1440).accepted, null); @@ -180,7 +183,7 @@ describe("--rerun-failed", () => { const dir = tempDir(); const routes = ["/", "/color", "/nav"]; const first = await runCli(args(routes, [], [1440, 375])); - assert.equal(first.code, 0, context(first)); + assert.equal(first.code, 1, context(first)); // Accept /color elsewhere: the rerun reads it from cwd and matches it against results.json. const accepted = await runCli(args(["/color"], ["--accept", "known"], [1440, 375]), { cwd: dir, @@ -196,7 +199,7 @@ describe("--rerun-failed", () => { cwd: dir, outDir: first.outDir, }); - assert.equal(run.code, 0, context(run)); + assert.equal(run.code, 1, context(run)); assert.deepEqual( [site.hits("/"), site.hits("/color")], [hits.home, hits.color], @@ -222,7 +225,7 @@ describe("--rerun-failed", () => { test("a run that doesn't repeat the previous one is refused", async () => { const first = await runCli(args(["/color"])); - assert.equal(first.code, 0, context(first)); + assert.equal(first.code, 1, context(first)); const again = (a: string[]) => runCli(a, { outDir: first.outDir }); for (const [a, needle] of [ [args(["/color"], ["--rerun-failed"], [375]), /--rerun-failed: widths \[375\] differ/], @@ -252,14 +255,14 @@ describe("--cache-right", () => { test("replays the right side's traffic on a repeat run, with the same results", async () => { const routes = ["/nav", "/color"]; const first = await runCli(args(routes, ["--cache-right"])); - assert.equal(first.code, 0, context(first)); + assert.equal(first.code, 1, context(first)); assert.match(first.stdout, /^right: loaded live and recorded for --cache-right/m); const was = results(first.outDir); assert.equal(was.meta.rightReplayedFrom, null); const hits = site.hits("/nav"); const again = await runCli(args(routes, ["--cache-right"]), { outDir: first.outDir }); - assert.equal(again.code, 0, context(again)); + assert.equal(again.code, 1, context(again)); assert.equal(site.hits("/nav"), hits + 1, "only the left side is loaded"); assert.match(again.stdout, /^right: replayed from a recording of \S+ \(--cache-right\)$/m); const now = results(again.outDir); @@ -277,7 +280,7 @@ describe("--cache-right", () => { const wider = await runCli(args([...routes, "/"], ["--cache-right"]), { outDir: first.outDir, }); - assert.equal(wider.code, 0, context(wider)); + assert.equal(wider.code, 1, context(wider)); assert.equal(site.hits("/nav"), hits + 3, "a shot the recording lacks loads it all live"); assert.match(wider.stdout, /^right: loaded live and recorded/m); }); @@ -341,12 +344,12 @@ describe("--cache-right", () => { right, ]; const first = await runCli(flaky); - assert.equal(first.code, 3, context(first)); + assert.equal(first.code, 1, context(first)); assert.match(first.stdout, /ERROR HTTP 500/, context(first)); const replay = [...args(["/nav"], ["--cache-right"], [375]), "--right", right]; const again = await runCli(replay, { outDir: first.outDir }); - assert.equal(again.code, 0, context(again)); + assert.equal(again.code, 1, context(again)); assert.match(again.stdout, /^right: replayed from/m, context(again)); } finally { proxy.closeAllConnections(); diff --git a/tests/visual/controls.test.ts b/tests/visual/controls.test.ts index 03b05d8..d9ab49c 100644 --- a/tests/visual/controls.test.ts +++ b/tests/visual/controls.test.ts @@ -15,8 +15,8 @@ * that font rendering cannot flip them, but far below parity. The point is direction, not a * particular percentage. * - * The second half checks the other half of the contract: a low score is only a *failure* when - * a threshold asked for one. + * The second half checks the other half of the contract: any difference fails the run, unless + * a threshold relaxes that. */ import assert from "node:assert/strict"; import fs from "node:fs"; @@ -72,9 +72,8 @@ after(async () => { cleanupTempDirs(); }); -test("a difference is not an error — the run still exits 0 without a threshold", () => { - // Scoring low is a measurement, not a failure. Only --threshold turns it into one. - assert.equal(run.code, 0, `expected exit 0 with no threshold set${context(run)}`); +test("a difference exits 1 without a threshold, and is not an error", () => { + assert.equal(run.code, 1, `expected exit 1 with no threshold set${context(run)}`); assert.deepEqual(report.errors, []); }); @@ -309,6 +308,7 @@ test("results.json carries the run meta and a summary that matches the report", assert.equal(summary.compared, report.cards.length); assert.equal(summary.errors, 0); assert.equal(summary.belowThreshold, 0); + assert.equal(summary.differing, rows.filter((r) => r.status === "compared").length); assert.equal( Number((summary.worst!.score * 100).toFixed(2)) / 100, Math.min(...report.cards.map((c) => c.score)), @@ -363,7 +363,7 @@ test("--progress prints a line per shot with the score results.json has", async ...renderdiffArgs({ left: site.left, right: site.right, routes: ["/nav"], widths: [1440] }), "--progress", ]); - assert.equal(r.code, 0, context(r)); + assert.equal(r.code, 1, context(r)); const [p] = parseProgress(r.stdout); const j = result(results(r.outDir), "/nav", 1440); assert.equal(p!.score, Number((j.score * 100).toFixed(2)) / 100, context(r)); @@ -461,17 +461,30 @@ test("--threshold turns a low score into a failure", async () => { assert.ok(r.report(), "no report on a threshold failure"); }); -test("the same run passes when no threshold is set", async () => { +test("any difference fails when no threshold is set", async () => { + const r = await runCli( + renderdiffArgs({ + left: site.left, + right: site.right, + routes: ["/shifted"], + widths: [1440], + }), + ); + assert.equal(r.code, 1, context(r)); + assert.match(r.stderr, /1 route\(s\) differ/); +}); + +test("--threshold 0 never fails on a difference", async () => { const r = await runCli( renderdiffArgs({ left: site.left, right: site.right, routes: ["/shifted"], widths: [1440], + threshold: 0, }), ); assert.equal(r.code, 0, context(r)); - assert.doesNotMatch(r.stderr, /below/); }); test("a threshold the run clears does not fail it", async () => { diff --git a/tests/visual/guardrails.test.ts b/tests/visual/guardrails.test.ts index 51b7105..3488775 100644 --- a/tests/visual/guardrails.test.ts +++ b/tests/visual/guardrails.test.ts @@ -60,7 +60,7 @@ after(async () => { /** One CLI run against the fixture site. */ const capture = ( routes: string[], - opts: { widths?: number[]; config?: string; selector?: string } = {}, + opts: { widths?: number[]; config?: string; selector?: string; extra?: string[] } = {}, ) => runCli([ ...renderdiffArgs({ @@ -72,6 +72,7 @@ const capture = ( config: opts.config, }), ...(opts.selector ? ["--selector", opts.selector] : []), + ...(opts.extra ?? []), ]); /** The report card for a route, with the run's context attached to any failure. */ @@ -260,6 +261,25 @@ describe("consent chrome", () => { }); }); +describe("the area ceiling", () => { + test("a long page is compared at a narrow width and refused at a wide one", async () => { + const run = await capture(["/long"], { widths: [375, 1440] }); + assert.equal(run.code, 3, context(run)); + const all = results(run.outDir); + assert.equal(result(all, "/long", 375).diffPixels, 0, context(run)); + assert.equal((await sharp(run.file("long.375.left.png")).metadata()).height, 50_000); + const wide = all.results.find((r) => r.width === 1440); + assert.ok(wide?.status === "error", context(run)); + assert.match(wide.error, /50000px tall at 1440px wide, past the 40000px sanity ceiling/); + }); + + test("a width past 1440 still gets the 40,000px ceiling", async () => { + const run = await capture(["/long"], { widths: [2560] }); + assert.equal(run.code, 0, context(run)); + assert.equal((await sharp(run.file("long.2560.left.png")).metadata()).height, 30_000); + }); +}); + describe("the tiled capture path", () => { let run: CliResult; @@ -399,6 +419,32 @@ describe("selector masks", () => { assert.equal(r.diffPixels, 0, `the selector mask did not cover the value${context(run)}`); assert.deepEqual([r.text.added, r.text.removed], [[], []], context(run)); }); + + test("--mask masks a selector on every route, without a config", async () => { + const run = await capture(["/drifting"], { extra: ["--mask", "[data-drift]"] }); + assert.equal(run.code, 0, context(run)); + assert.equal(result(results(run.outDir), "/drifting", 1440).diffPixels, 0, context(run)); + assert.deepEqual(parseReport(run.report()!).maskReasons, ["[data-drift] (--mask)"]); + }); + + test("--mask adds to the config's masks", async () => { + const run = await capture(["/drifting"], { + config: path.join(CONFIGS, "mask-selector.mjs"), + extra: ["--mask", "iframe"], + }); + assert.deepEqual(parseReport(run.report()!).maskReasons, [ + "render counter, by selector", + "iframe (--mask)", + ]); + }); + + test("--mask-media paints iframes, video and video.js text tracks", async () => { + const bare = await capture(["/media"]); + assert.ok(result(results(bare.outDir), "/media", 1440).diffPixels > 0, context(bare)); + const run = await capture(["/media"], { extra: ["--mask-media"] }); + assert.equal(run.code, 0, context(run)); + assert.equal(result(results(run.outDir), "/media", 1440).diffPixels, 0, context(run)); + }); }); describe("route pairs", () => { @@ -469,7 +515,7 @@ describe("component scope", () => { test("an element with no text that differs only in colour is scored, not refused as blank", async () => { const run = await scoped(["/stripe"], ["--selector", ".plain"]); - assert.equal(run.code, 0, context(run)); + assert.equal(run.code, 1, context(run)); const r = result(results(run.outDir), "/stripe", 1440); assert.ok(r.score < 1 && r.diffPixels > 0, context(run)); }); @@ -496,7 +542,7 @@ describe("component scope", () => { test("the recoloured swatch alone scores low, with its region in the element's own pixels", async () => { const run = await scoped(["/color"], ["--selector", SWATCH, "--progress"]); - assert.equal(run.code, 0, context(run)); + assert.equal(run.code, 1, context(run)); const r = result(results(run.outDir), "/color", 1440); assert.deepEqual(r.selector, { left: SWATCH, right: SWATCH }); assert.equal(r.totalPixels, 208 * 160, context(run)); @@ -530,7 +576,7 @@ describe("component scope", () => { ], { noOut: true }, ); - assert.equal(again.code, 0, context(again)); + assert.equal(again.code, 1, context(again)); }); test("a mask is painted in the element's coordinates", async () => { @@ -551,7 +597,7 @@ describe("component scope", () => { [PAIR], ["--left-selector", ".swatch >> nth=0", "--right-selector", ".swatch >> nth=1"], ); - assert.equal(run.code, 0, context(run)); + assert.equal(run.code, 1, context(run)); const r = result(results(run.outDir), PAIR, 1440); assert.deepEqual(r.selector, { left: ".swatch >> nth=0", right: ".swatch >> nth=1" }); assert.deepEqual([r.text.added, r.text.removed], [["One"], ["Two"]], context(run)); @@ -601,7 +647,7 @@ describe("before hooks", () => { const run = await hooked( '{ routes: [{ left: "/menu", before: async (page) => { await page.click("#toggle"); } }] }', ); - assert.equal(run.code, 0, context(run)); + assert.equal(run.code, 1, context(run)); const r = result(results(run.outDir), "/menu", 1440); // Each side's panel says something different, so this only differs if both opened. assert.ok(r.diffPixels > 0, `the hook did not run before the shot${context(run)}`); @@ -621,7 +667,7 @@ describe("before hooks", () => { 'await page.locator("h1").evaluate((h, t) => (h.textContent = t), `${side} ${route} ${width}`); } }', ["/menu"], ); - assert.equal(run.code, 0, context(run)); + assert.equal(run.code, 1, context(run)); const r = result(results(run.outDir), "/menu", 1440); assert.deepEqual( [r.text.added, r.text.removed], @@ -703,7 +749,7 @@ describe("storage state", () => { ], { cwd }, ); - assert.equal(run.code, 0, context(run)); + assert.equal(run.code, 1, context(run)); const res = results(run.outDir); const r = result(res, "/signed-in", 1440); assert.deepEqual( @@ -720,7 +766,7 @@ describe("storage state", () => { const dir = authIn(tempDir()); fs.writeFileSync(path.join(dir, "c.mjs"), 'export default { storageState: "auth.json" };\n'); const run = await capture(["/signed-in"], { config: path.join(dir, "c.mjs") }); - assert.equal(run.code, 0, context(run)); + assert.equal(run.code, 1, context(run)); const res = results(run.outDir); const r = result(res, "/signed-in", 1440); assert.deepEqual( @@ -840,7 +886,7 @@ describe("network blocking", () => { describe("crops", () => { test("a change too tall for one legible crop is clipped to its top, not shrunk or split", async () => { const run = await capture(["/tall-region"]); - assert.equal(run.code, 0, context(run)); + assert.equal(run.code, 1, context(run)); const r = result(results(run.outDir), "/tall-region", 1440); assert.equal(r.crops.length, 1, context(run)); const [c] = r.crops; @@ -893,7 +939,7 @@ describe("element attribution", () => { const [e] = result(results(run.outDir), "/labelled", 1440).regions[0]!.elements!; assert.match(e!.selector, /aria-label="Second\\a block"/, context(run)); const again = await capture(["/labelled"], { selector: e!.selector }); - assert.equal(again.code, 0, context(again)); + assert.equal(again.code, 1, context(again)); assert.equal(result(results(again.outDir), "/labelled", 1440).selector?.left, e!.selector); }); }); @@ -1015,19 +1061,19 @@ describe("the output directory", () => { test("a previous run with region crops and results.json is wiped and reused", async () => { const dir = path.join(tempDir(), "out"); const first = await into(dir, ["/color"]); - assert.equal(first.code, 0, context(first)); + assert.equal(first.code, 1, context(first)); assert.ok(fs.existsSync(path.join(dir, "color.1440.c1.png")), context(first)); assert.ok(fs.existsSync(path.join(dir, "results.json"))); const second = await into(dir, ["/color"]); - assert.equal(second.code, 0, context(second)); + assert.equal(second.code, 1, context(second)); }); test("a previous run of a route pair is wiped and reused", async () => { const dir = path.join(tempDir(), "out"); const first = await into(dir, ["/flex-vs-grid::/float-vs-flex"]); - assert.equal(first.code, 0, context(first)); + assert.equal(first.code, 1, context(first)); const second = await into(dir, ["/flex-vs-grid::/float-vs-flex"]); - assert.equal(second.code, 0, context(second)); + assert.equal(second.code, 1, context(second)); assert.doesNotMatch(second.stderr, /refusing to wipe/, context(second)); });