Vizuális regressziós tesztek
Stabil képernyőkép-összevetést készít a szándékos változás és hiba elválasztására, a képet nem tekintve interakciós bizonyítéknak.
visual-regression-testing
Nézd meg, miben segítMikor hasznos?
Akkor használd, ha közös komponens vagy elrendezés több állapotban és témában igényel ismételhető látványvédelmet.
Miben segít neked?
- Szabályozza az időt, adatot, betűt, animációt és nézeteltérést.
- Célzott komponensképet és reprezentatív összetett képernyőt választ.
- Alapképfrissítés előtt megvizsgálja az eltérést, megőrzi a működési tesztet.
Például ezt kérheted
Adj stabil ablakpillanatképet hiba- és sötét állapotra elrendezési hibák elfedése nélkül. Helyi próbában távolíts el hibacímkét, hogy kiderüljön, észleli-e a képi teszt. Új alap elfogadása előtt vizsgáld a szándékos változást.
Részletes dokumentáció
Itt a skill eredeti útmutatóját, példáit és ellenőrzési szempontjait olvashatod az eredeti nyelven.
Összecsukás
Visual Regression Testing
Visual regression tests catch unintended layout shifts, broken CSS tokens, z-index collisions, clipped text and dark-mode contrast regressions that unit assertions miss. However, poorly configured screenshot tests become flaky noise if non-deterministic inputs are not controlled.
1. Controlling Non-Determinism for Zero-Flake Baselines
Before capturing a screenshot baseline (Playwright toHaveScreenshot(), Chromatic, Percy or Storybook test runner), lock down every source of visual variance:
- Freeze time, random IDs & dynamic data:
- Inject a fixed clock (
page.clock.setFixedTime(...)) so relative timestamps ("3 minutes ago", calendar pickers) render identically on every run. - Use deterministic fixture data — never random faker output or live network responses.
- Inject a fixed clock (
- Disable animations, transitions & blinking carets:
- Set
animations: 'disabled'andcaret: 'hide'in screenshot options (or injectprefers-reduced-motion: reduce), and pause any JS timers, canvas loops or video frames at a deterministic tick.
- Set
- Wait for fonts, images & layout stability:
- Await
document.fonts.readyand ensure local web fonts and SVG/icon assets have finished loading before capturing; missing fonts cause massive false-positive text diffs across OS environments.
- Await
- Pin viewport, device scale factor & color scheme:
- Explicitly declare the viewport matrix (e.g.,
1280x800desktop,768x1024tablet,375x667mobile,320x568reflow) and theme (lightvs.dark) as part of the test setup.
- Explicitly declare the viewport matrix (e.g.,
2. Component-Scoped vs. Full-Page Snapshots
- Prefer component/locator screenshots (
locator.screenshot()) for testing variants, interactive states (:hover,:focus-visible,error,disabled) and edge cases in isolation — they run fast and localize failures to the exact primitive. - Use targeted full-page or section snapshots for representative product screens where layout composition, sticky headers, sidebars and modal backdrops interact.
3. Disciplined Diff Triage (Never Blindly Update Snapshots)
When a visual test fails:
- Inspect the visual diff image pixel-by-pixel (baseline vs. actual vs. diff overlay) before deciding whether to update the baseline.
- Distinguish three categories:
- Intentional visual change: matches the task specification and design tokens -> update the baseline and document why in the handoff.
- Unintended regression: a token or CSS edit leaked into an unrelated component, broke alignment or clipped overflow -> fix the CSS/component bug!
- Environmental noise: font-hinting differences between macOS and Linux CI containers -> run baseline generation in the same browser/OS environment as CI or scope masks (
mask: [locator]) only to genuinely volatile third-party embeds.
- Pair visual checks with behavioral tests: a screenshot proves how a component looks, never whether clicking it fires the right callback or traps keyboard focus.
Csomagban lévő fájlok 1
SKILL.md
