Safeguard
Developer Tools•

Does visual regression testing catch a bad dependency update?

Visual regression tests catch rendering changes from a dependency update, not security flaws or data behavior. What they cover and where they stop.

Safeguard Security Team
4 min read

Partly. Visual regression tests catch a dependency update that changes how a component looks, such as spacing, fonts or a missing icon. They do not catch a new vulnerability, a changed network call or a logic bug that leaves pixels the same. Treat them as one gate among several.

How visual tests work

A visual test takes a screenshot of a component or page and compares it against a stored baseline. Playwright's documentation describes this plainly: the first run generates reference screenshots, and later runs compare against them. Storybook's visual testing guide turns every story into a test in the same way.

That design is why they suit a design system. A shared button or table is rendered in many states, and a small change in a styling dependency can shift all of them at once.

What they catch after an update

Update typeVisual test catches it?
CSS or styling runtime bump changes spacingLikely
Icon or font package changes glyphsLikely
Animation library changes timingSometimes, if a test waits for a settled state
Date or number formatting library changes output textYes, if the story shows the text
Hover, focus and error statesOnly if a story renders them
Hidden behavior such as event handlersNo
Security flaws, data handling, network callsNo

Limits to plan for

Playwright warns that browser rendering can vary by host, and that screenshots differ across browsers and platforms because of rendering and fonts. Snapshots are stored per browser and platform for that reason. In practice, generate baselines in the same environment that CI uses, or you will chase false diffs.

Visual tests also depend on story coverage. A state with no story is invisible to them. After a dependency update, the question "did tests pass" means "did the states we thought of still look right".

Pair them with other gates

  1. Unit and interaction tests for behavior the screenshot cannot show.
  2. A dependency scan on the update pull request, so a clean visual run is not read as a clean security result.
  3. A type check and a build of a sample consuming app, which catches export changes.
  4. A manual review of the changelog for the updated package, focused on removed or renamed options.

Together these give you a defensible merge rule for update bots: automerge only when visual, unit and scan checks are all green and the change is a patch or a minor in a non critical package.

How to review a visual diff in an update PR

Open the diff images before the code. If the change is a one pixel shift in many components, find the shared token or style rule that moved, and check the package changelog. If a single component changed, read that component's usage. Accept the new baseline only with a note in the pull request saying why the change is intended.

Try it yourself

Click through it at your own pace, or open it full screen. Look at how a pull request is checked by more than one gate before it can merge.

Quick check

Can visual tests replace a vulnerability scan on update PRs?

No. They answer a different question. Run both so a good looking page is not mistaken for a safe dependency.

Why do my baselines differ between my laptop and CI?

Rendering varies by host, as the Playwright documentation notes. Create and update baselines in the CI environment.

Safeguard adds the scan side of that gate, with policies that can block a pull request on new vulnerable dependencies. You can try a free scan at gold.safeguard.sh/scan.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.