Percy · visual testing

On this page 6

Percy is a cloud-based visual testing service that captures snapshots of web pages or components during automated tests, renders them in several browsers and widths, and compares them with approved baseline images to detect unintended visual changes. In web testing, Percy belongs to the category of visual regression tools, and it has been part of the BrowserStack product portfolio since 2020.

Functional tests confirm that a button works; Percy confirms that it still looks right. It catches shifted layouts, broken fonts, overlapping elements and color changes that assertion-based tests in Playwright, Cypress or Selenium normally miss.

How Percy captures and compares snapshots

Percy does not take screenshots inside the test runner. Its SDK captures a DOM snapshot: the serialized HTML of the page together with the CSS, fonts and images it references. The snapshot is uploaded to the Percy service, where Percy renders it again in controlled browser environments. This approach removes much of the noise caused by local machines, operating systems and font rendering differences.

Each rendered image is compared with the baseline snapshot from the base branch, usually main. Percy highlights changed pixels in a visual diff overlay, and a reviewer approves or rejects each change. Approved images become the new baseline when the branch is merged. The table below follows a snapshot through the pipeline.

StageWhat happensWhere it runs
CaptureSDK serializes DOM and assetsTest runner in CI
UploadSnapshot and resources are sent to PercyPercy CLI
RenderPage is rendered per browser and widthPercy cloud infrastructure
ComparePixels are diffed against the baselinePercy cloud infrastructure
ReviewHumans approve or request changesPercy web dashboard
Stages of a Percy visual test

Integrations and configuration

Percy offers SDKs for common test frameworks, including Playwright, Cypress, Selenium WebDriver, Puppeteer, WebdriverIO and Storybook. A test calls a function such as percySnapshot(page, 'Checkout') at the moment the interface is in the desired state. The run is wrapped with the Percy CLI, for example npx percy exec -- npx playwright test, which starts a local server that collects snapshots.

A project token stored as the `PERCY_TOKEN` environment variable links the build to a Percy project. Configuration in .percy.yml sets widths, browsers and CSS overrides. The following parameters have the greatest effect on cost and reliability.

ParameterTypical valueWhat it affects
Widths375, 768 and 1280 pixelsResponsive layouts covered per snapshot
BrowsersChrome, Firefox, Safari, EdgeCross-browser rendering coverage
Minimum height1024 pixelsCaptured area of short pages
Percy CSSRules that hide dynamic elementsFewer false positives
Diff sensitivityProject-level thresholdHow small a change is flagged
Key Percy configuration parameters

Billing is based on screenshots, not snapshots. One snapshot rendered at three widths in four browsers produces twelve screenshots, so the width and browser matrix should match real user traffic rather than every possible combination.

Percy compared with other visual testing approaches

Teams can implement visual regression checks in several ways, from free local screenshot comparison to managed services. Percy sits at the managed, review-centered end of this spectrum, which suits teams that want consistent rendering and a shared approval workflow.

ApproachRendering locationStrengthWeakness
PercyVendor cloudStable rendering and review dashboardPaid per screenshot
Playwright screenshot assertionsLocal or CI machineFree and built into the runnerBaselines differ across operating systems
Applitools EyesVendor cloudAI-based visual matchingHigher cost and complexity
ChromaticVendor cloudTight Storybook integrationFocused on components
Visual testing options compared

Percy complements rather than replaces functional and accessibility testing. A page can look identical to its baseline and still have a broken form handler or missing labels, so visual checks work best as one layer in a test pyramid.

Choosing where to place snapshots matters as much as choosing the tool. Component-level snapshots from Storybook isolate design system changes and run quickly, while page-level snapshots from end-to-end tests reveal how components interact in real layouts. Many teams use both: a broad component suite on every pull request and a smaller set of critical pages such as login, search and checkout. This balance keeps screenshot budgets predictable while still covering the flows that generate revenue or support requests.

Limitations and practical pitfalls

The most common problem with Percy is flaky diffs caused by dynamic content. Timestamps, rotating banners, animations, randomized test data and third-party ads change between runs and produce differences that are not regressions. Stabilizing the page before capture is essential.

SymptomCauseRemedy
Diff on every buildDates or random data in the pageFreeze clocks and seed test data
Partially loaded imagesSnapshot taken before assets finishedWait for network idle before capture
Animation frames differCSS transitions still runningDisable animations with Percy CSS
Missing fonts or iconsAssets blocked or served from auth-protected hostsAllow asset discovery for those hosts
Typical Percy problems and remedies
  • Reviewer fatigue sets in when too many trivial diffs appear, and real regressions get approved by habit.
  • Because snapshots are serialized DOM, canvas, WebGL and some iframe content may not render as in a live browser.
  • Snapshots of pages with personal data are uploaded to a third-party cloud, so test fixtures should use synthetic data.

The simple explanation

Percy is like a spot-the-difference game played by a computer. Every time developers change a website, Percy takes pictures of the important pages and lays them over the pictures from the last approved version.

If anything moved, changed color or disappeared, Percy marks the spot in red. A person then decides whether the change was intended or a mistake. This catches visual problems before customers ever see them, even when nobody thought to check that particular page.

How it is used in practice

An online retailer maintains a design system shared by its storefront and checkout. A developer updates a spacing token in the button component and opens a pull request. The continuous integration pipeline runs Playwright end-to-end tests wrapped with the Percy CLI, capturing 60 snapshots at widths of 375 and 1280 pixels in Chrome and Safari.

All functional tests pass, but Percy reports changes on 14 snapshots. Most show the intended wider padding. On the mobile checkout page, however, the wider button pushes the payment total below the fold and overlaps a legal notice. The reviewer requests changes directly in the Percy dashboard, and the pull request status stays blocked.

The developer adjusts the mobile layout, the next build shows only intended differences, and the reviewer approves them. The new images become the baseline after merge, and a checkout defect that functional tests could not detect never reaches production.