page-visual-tests

Captures full-page DOM snapshots of ethereum.org pages with Playwright and Chromatic for visual regression testing.

6.0k|5.4k|Updated Jan 6, 2018
One-click install
npx skills add https://github.com/ethereum/ethereum-org-website --skill page-visual-tests
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: page-visual-tests
Source: https://github.com/ethereum/ethereum-org-website/tree/main/.claude/skills/page-visual-tests
Command: npx skills add https://github.com/ethereum/ethereum-org-website --skill page-visual-tests

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires @chromatic-com/playwright, @playwright/test.

What problem does it solve?

Full-page visual regressions on ethereum.org are hard to catch with unit or e2e tests, and Playwright + Chromatic page snapshots flake easily due to loaders, random ordering, viewport limits, and dual Playwright configs. This Skill encodes the non-obvious constraints so you can add pages to the visual suite and debug flaky snapshots without rediscovering each pitfall.

Core Features & Use Cases

  • Add pages to the visual suite: Guidance on snapshot budget (3 viewports per page), layout coverage checks, and the canonical test pattern using @chromatic-com/playwright.
  • Diagnose flaky snapshots: Systematic checks for bespoke loaders missing data-slot="loading", unseeded random ordering that needs safeShuffle, and missing USE_MOCK_DATA or HOME environment variables.
  • Respect infrastructure constraints: Explains the dual Playwright config split, the 1024px desktop viewport driven by Chromatic's 25M-pixel cap, and why domcontentloaded is used instead of networkidle.
  • Use Case: A developer adds a new long page to tests/visual/pages.spec.ts and the Chromatic build fails with a pixel-limit error; the Skill walks them through measuring document.documentElement.scrollHeight at 1024px and deciding whether to shorten or drop the page.

Quick Start

Add the /wallets/ page to the visual test suite and make sure its snapshots are stable.

Frequently Asked Questions about page-visual-tests

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a page to the Playwright Chromatic visual test suite?

Add an entry with name and unprefixed path to the pages array in tests/visual/pages.spec.ts. Each entry costs three snapshots (one per viewport), so first check whether the page's layout is already covered and confirm its full-page height stays under the 25M-pixel budget.

Why does my Chromatic page snapshot keep changing between runs?

Flaky snapshots usually come from a loader missing the data-slot="loading" attribute or from random ordering via lodash shuffle or Math.random sorts. Route loaders through the shared Skeleton or Spinner primitives and wrap shuffles with safeShuffle from src/lib/utils/random.ts.

Why is the desktop viewport 1024 instead of 1280 in Playwright visual tests?

Chromatic caps snapshots at 25 million pixels (width times height). The tallest tested pages reach about 22,500 px, so 1280 overflows the limit while 1024 fits. Measure document.documentElement.scrollHeight before raising the viewport or adding a long page.

Can I import test and expect from @playwright/test in Chromatic visual tests?

No, imports must come from @chromatic-com/playwright. The two packages re-export expect with skewed types, so assertions like toHaveCount misbehave. Prefer page.waitForFunction for the loading wait instead.

Why do Playwright visual tests pass locally but fail in CI?

The usual cause is a missing HOME: /root variable in the CI test step, since GitHub Actions overrides HOME inside containers and Playwright cannot find browsers baked into the mcr.microsoft.com/playwright image. Also verify the image tag matches @playwright/test in package.json.

Should I use networkidle or domcontentloaded for page visual tests?

Use domcontentloaded. Analytics and background fetches keep the network perpetually busy on ethereum.org, so networkidle never settles and causes timeouts or flakes.