DEV.co
Open-Source Testing · americanexpress

jest-image-snapshot

jest-image-snapshot is a Jest plugin that captures and compares visual screenshots to detect unintended UI changes. It stores baseline images and flags differences on subsequent test runs, making it ideal for visual regression testing in browser-based applications.

Source: GitHub — github.com/americanexpress/jest-image-snapshot
3.9k
GitHub stars
209
Forks
JavaScript
Primary language
Apache-2.0
License (OSI-approved)

Key facts

Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.

FieldValue
Repositoryamericanexpress/jest-image-snapshot
Owneramericanexpress
Primary languageJavaScript
LicenseApache-2.0 — OSI-approved
Stars3.9k
Forks209
Open issues41
Latest releasev6.5.2 (2026-03-09)
Last updated2026-06-22
Sourcehttps://github.com/americanexpress/jest-image-snapshot

What jest-image-snapshot is

A Jest matcher extension that performs pixel-level or structural similarity (SSIM) image comparisons using pixelmatch, generating diff reports and supporting customizable thresholds, Gaussian blur, and snapshot management. Requires Jest 20–29 as a peer dependency.

Quickstart

Get the jest-image-snapshot source

Clone the repository and explore it locally.

terminalbash
git clone https://github.com/americanexpress/jest-image-snapshot.gitcd jest-image-snapshot# follow the project's README for install & configuration

Need it deployed, integrated, or customized instead? DEV.co ships production installs.

Best use cases

Visual Regression Detection in Component Libraries

Catch unintended visual changes in UI components across browser/resolution combinations by comparing rendered screenshots against baseline snapshots before deployment.

End-to-End UI Testing

Integrate with Puppeteer or Playwright to automate full-page screenshot comparisons, detecting layout shifts, styling regressions, or rendering bugs in production-like environments.

Cross-Browser Visual Consistency Validation

Maintain pixel-perfect consistency across browsers and devices by storing and comparing snapshots, with configurable thresholds to tolerate minor anti-aliasing or rendering variations.

Implementation considerations

  • Ensure deterministic rendering: seed randomness, mock timers, and disable animations to produce stable baselines on first run.
  • Configure thresholds appropriately—pixelmatch threshold (per-pixel) vs. failureThreshold (image-wide)—to avoid false positives from anti-aliasing or minor rendering variance.
  • Plan snapshot storage and Git LFS integration early; binary image files bloat repositories; consider CI artifact storage or external snapshot registries.
  • Set up baseline image review and approval workflows before committing snapshots; unreviewed baselines defeat the purpose of visual regression detection.
  • Use customDiffDir and customReceivedDir to separate diff/received images from baselines for easier CI artifact inspection and baseline updates from isolated test runs.

When to avoid it — and what to weigh

  • Jest Version Outside 20–29 — The project explicitly requires Jest >=20 <=29. Do not attempt integration with Jest 30+ or earlier than v20; compatibility is not guaranteed and may break.
  • Highly Dynamic or Non-Deterministic UIs — Avoid if your application renders timestamps, random colors, animations, or content that changes on every render without explicit seeding; snapshots will fail unpredictably.
  • Rapid Image Format or Screenshot API Changes — If your pipeline depends on bleeding-edge browser automation APIs or image codecs, snapshot stability may suffer; test framework updates can orphan stored baselines.
  • High-Volume Snapshot Storage Constraints — Large test suites generating thousands of image snapshots consume significant disk space. Verify storage capacity and CI artifact retention policies beforehand.

License & commercial use

Licensed under Apache License 2.0 (Apache-2.0), a permissive OSI-approved license. Allows commercial use, modification, and redistribution with attribution and liability disclaimers.

Apache-2.0 is a permissive license generally allowing commercial use, modification, and redistribution. However, confirm your legal team has reviewed compliance with your specific usage context (distribution, bundling, etc.) before deploying in production software.

DEV.co evaluation signals

Editorial assessment — not user reviews. Directional, with an explicit confidence level.

SignalAssessment
MaintenanceActive
DocumentationAdequate
License clarityClear
Deployment complexityLow
DEV.co fitGood
Assessment confidenceHigh
Security considerations

No security audit or vulnerability disclosure process mentioned in data. As a test utility, it runs during development/CI and processes image files; no network calls or cryptographic operations evident. Verify dependencies (pixelmatch, ssim.js) for known vulnerabilities before production CI integration. Sensitive baseline images may be exposed in repositories or CI logs if not properly gitignored or artifact-gated.

Alternatives to consider

Percy.io (SaaS)

Cloud-hosted visual regression with AI-powered change detection, cross-browser testing, and centralized approval workflows—better for teams prioritizing managed infrastructure over self-hosted storage.

Playwright Test (native assertions + snapshots)

Built-in visual assertions and snapshot comparison for Playwright tests (Jest-compatible); avoids external plugin dependency if already using Playwright for E2E automation.

BackstopJS

Standalone visual regression tool with headless browser support, multi-viewport testing, and reference image management—suits teams avoiding Jest or needing standalone configuration.

Software development agency

Build on jest-image-snapshot with DEV.co software developers

jest-image-snapshot integrates seamlessly with Jest-based test suites. Review the setup requirements (Jest 20–29, storage planning) and explore examples on GitHub to get started.

Talk to DEV.co

Related open-source tools

Surfaced by semantic similarity across the DEV.co open-source index.

Related on DEV.co

Explore the category and the services that help you build with it.

jest-image-snapshot FAQ

Does jest-image-snapshot work with Jest 30 or higher?
No. The project explicitly requires Jest >=20 <=29. Jest 30+ is unsupported; use an alternative or wait for an updated release if your project has moved to Jest 30+.
How do I avoid snapshot failures due to anti-aliasing or minor rendering noise?
Use customDiffConfig.threshold to increase per-pixel sensitivity (default 0.01), apply blur (1–2 pixel radius) to smooth minor variations, or use SSIM comparison method for structural tolerance instead of pixel-perfect matching.
Can I store snapshots outside my Git repository?
Yes, use customSnapshotsDir to point to an external path (e.g., cloud storage or CI artifact directory). Manage baseline versioning and distribution separately; Git LFS is one common approach for binary snapshot storage.
What happens if my screenshots have different dimensions?
By default, size mismatches cause test failure. Set allowSizeMismatch: true to ignore dimensional differences; useful for responsive design testing across device sizes.

Custom software development services

DEV.co helps companies turn open-source tools like jest-image-snapshot into production software. Our software development services cover the full lifecycle — architecture, web development, integration, and maintenance — delivered by software developers and web developers who ship. Engage our software development agency to implement or customize it for your open-source testing stack.

Ready to prevent visual regressions in your UI tests?

jest-image-snapshot integrates seamlessly with Jest-based test suites. Review the setup requirements (Jest 20–29, storage planning) and explore examples on GitHub to get started.