snapshottest
Snapshot testing for pytest, unittest, Django, and Nose
What it is and what it does
Snapshot testing lets you capture the state of an API response or other serializable output once, store it as a reference file, and then automatically compare future test runs against that snapshot. Instead of writing explicit assertions for every field in a response, you assert that the output matches the saved snapshot; if it changes, the test fails and you can review the diff to decide whether the change is expected (and update the snapshot) or a regression.
The package integrates with pytest, unittest, Django, and nose, so it fits into existing test suites. It depends on six, termcolor, and fastdiff to handle cross-version compatibility, colored diff output, and efficient comparison. The workflow is: write a test that calls your API, call snapshot.assert_match() or self.assertMatchSnapshot(), and on first run it saves the response; on subsequent runs it compares. You can update snapshots in bulk with a command-line flag when changes are intentional.
Use it for:
- Testing REST API endpoints by capturing and comparing full JSON responses without hand-writing field assertions
- Regression testing UI component serialization or GraphQL query results across code changes
- Validating complex nested data structures where manual assertion would be tedious and brittle
- Bulk-updating test expectations after intentional API schema changes using --snapshot-update
- Documenting expected API behavior by reviewing snapshot diffs in version control
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Snapshot testing library that captures API responses or other serializable outputs and compares them against stored reference snapshots, supporting pytest, unittest, Django, and nose test runners.
Yes, with caution on maintenance. Snapshot testing is a proven pattern and this package is stable and widely used. However, it has been dormant since 2020-09-29 with no recent commits—if you need active maintenance, bug fixes, or support for cutting-edge test frameworks, consider whether a more actively maintained alternative fits your timeline. For established projects with stable test suites, it remains a solid choice.
Install
snapshottest on PyPI
pip
pip install snapshottestuv
uv add snapshottestpoetry
poetry add snapshottestInstalling snapshottest
Before you install
Low friction install with three lightweight runtime dependencies (six, termcolor, fastdiff). Maintenance is dormant—last release was 2020-09-29 and no commits since 2024-08-01—so expect no active bug fixes or feature development, though the package is marked Production/Stable.
License in practice
MIT license is permissive; you can use, modify, and distribute this package freely in commercial and open-source projects with minimal restrictions.
Quickstart
pip install snapshottest
# With pytest:
from snapshottest import snapshot
def test_api(snapshot):
response = api.client.get('/me')
snapshot.assert_match(response)
# With unittest:
from snapshottest import TestCase
class APITest(TestCase):
def test_api(self):
response = api.client.get('/me')
self.assertMatchSnapshot(response)
Verify before relying
- Whether the package works reliably with modern Python versions beyond 3.8, given the last release was 2020-09-29
- Current compatibility status with recent versions of pytest, unittest, and Django test runners
- Whether dormant status means critical bugs or security issues would go unpatched
Package facts
| License | MIT (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — six, termcolor, fastdiff |
| Maintenance | dormant — 2,145 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 488,476/month — #6,380 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: snapshottest-0.6.0-py2.py3-none-any.whl
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
pytest-snapshotA pytest plugin that enables snapshot…
permissive · top 5,000 on PyPI
snapshot-restore-pyRegisters runtime hooks in AWS Lambda…
permissive · top 5,000 on PyPI
pytest-instaA pytest plugin that enables snapshot testing…
unclear · top 15,000 on PyPI
syrupySyrupy is a pytest plugin that enables snapshot…
permissive · top 5,000 on PyPI
inline-snapshotinline-snapshot is a pytest plugin that lets…
permissive · top 5,000 on PyPI
expecttestexpecttest implements inline golden tests where…
permissive · top 5,000 on PyPI
pytest-textual-snapshotA pytest plugin that captures SVG screenshots…
permissive · top 15,000 on PyPI
pynosepynose is an updated test runner that extends…
copyleft · top 5,000 on PyPI
pytest-playwright-visualA pytest plugin that captures and compares…
permissive · top 15,000 on PyPI
core-universalProvides the Applitools Eyes Core SDK Server…
unclear · top 15,000 on PyPI