← All posts

Catch flaky examples before they reach your baseline

Joe Lencioni
, Founder and CTO

A new example has no baseline to compare it with, so a flaky one used to get accepted without anyone noticing. Happo now renders every added example a few more times and flags the ones that don't come out the same, so you can fix them before they turn into spurious diffs. A new blockApproval option can keep a comparison from being approved until you do.

A Happo comparison page with an added example, ui/DeployStatus, a card reading "Last deploy: Nov 10, 2026". Above the card, a Detected flake notice says Happo rendered this added example a few times and found that it came out different on another date, with a Compare renders button.

Most flaky diffs start out as an accepted snapshot that was flaky all along.

When you add a story or a test, Happo shows its snapshot as Added. It has no baseline yet, so there is nothing to compare it with. A reviewer looks at it, it looks right, and it gets accepted. If it shows today's date, catches an image before it loads, or stops an animation at a different frame each time, none of that shows up in this pull request. It shows up later, as a diff in somebody else's pull request, for a change they didn't make.

Starting today, Happo checks every added example for flakiness before you accept it. And if you want to make sure a flaky example never gets accepted, a new config option blocks approval until it's fixed.

How it works

When a comparison has added snapshots, Happo renders each added example again in the same browser and viewport:

  • Once as it was. This catches timing problems: late images, unfinished animations and races between data and rendering.
  • Once as if it were another date. Happo moves the page's clock about a year ahead, which catches examples that show the current date or something worked out from it, like "3 days ago" or the year in a footer. Only Date moves, so timers and animations run as they did in the original render. iOS Safari can't set the clock, so there the example is rendered again once, without the date change.

If a render comes out different from the one in the report, the example gets a Detected flake notice on the comparison page. A difference only counts if a comparison would show it as a diff, so your project's compare threshold and the diffs you have ignored apply here too.

While Happo is still rendering, the notice says Checking for flakes. You can start reviewing right away: the comparison isn't held up in the meantime unless you block approval on flaky examples (more on that below).

What to do with a flaky example

Click Compare renders in the notice to see the report's render next to the one that came out differently, as a side-by-side, a diff or a swipe. That usually makes the cause obvious.

The Compare renders dialog, side by side. The render in the report shows "Last deploy: Nov 10, 2026", and the render on another date shows the same card with "Dec 15, 2027".

When the notice says the example came out different on another date, the example shows the date. Pass a fixed date to the component, or freeze time with a library like mockdate or Sinon.js. When it came out different on a repeat render, look for content that loads late, animations, random data and generated ids. Spurious diffs has tips for the most common causes.

Then fix the example before you accept it. Accepting a flaky example makes it part of the baseline, and every later run gets a chance to differ from it. Fixed in the pull request that adds it, it never causes a spurious diff for anyone.

There is nothing to report as a flake here. Reporting a diff as flaky tells Happo to ignore that exact before-and-after pair, but an added snapshot has no before, and the flakiness lives in the example itself. The fix belongs in your code or your test setup.

Blocking approval

The notice tells a reviewer an example is flaky, but nothing stops them from accepting it anyway. To make sure a flaky example can't get into your baseline, turn on flakyAddedSnapshots in the blockApproval option of your Happo config:

// happo.config.ts
import { defineConfig } from 'happo';

export default defineConfig({
  // ...

  blockApproval: {
    flakyAddedSnapshots: true,
  },
});

With it on, a comparison with a flaky added example can't be approved:

  • The Accept button on the comparison page is disabled and says the added examples are flaky
  • Approving through the API responds with a 409, and an AI assistant approving through the MCP server is refused the same way
  • The status on the pull request stays failed until you fix the example and Happo runs again

Approval also waits while Happo is still checking the added examples, which usually takes a few minutes. An approval carried over from an earlier commit lands once the check finds nothing flaky. An example Happo couldn't render again doesn't block anything.

Unlike blockApproval's other conditions, flakyAddedSnapshots is off unless you set it, since it makes every comparison that adds examples wait on the check. Because it lives in your config, you can turn it on in one pull request and fix any flaky examples there without affecting other work in the repository.

AI assistants see it too

If you review comparisons with an AI assistant through the Happo MCP server, it sees the same check. get_comparison_details tells the assistant which added snapshots are flaky and whether it was the date that changed them, so it can tell you before you accept them, and suggest a fix.

Pricing and requirements

The extra renders are free. They don't count toward your snapshot usage or quota: only the snapshots in your reports do.

The check is on for every account on happo.io, with no change to your config. A comparison that adds many examples, such as a project's first, can take a while to check.

blockApproval.flakyAddedSnapshots needs happo 7.4.0 or later.

See Detected flakes in new examples and the blockApproval reference in the docs for more.

Enjoying this?

Subscribe to get new posts on visual and accessibility regression testing delivered to your inbox. Subscribe →

About Happo

Happo is founder-led visual and accessibility regression testing for your PR workflow — built and supported directly by Henric and Joe since 2014. See what's new → or start a trial →.

Related posts

Need help?