Syrupy is a pytest plugin for snapshot testing, enabling developers to capture the current output of a value and compare it against a previously stored snapshot. It's currently on version 5.1.0 and maintains an active release cadence, typically releasing minor/patch versions every 1-3 months.
pip install syrupyVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates a basic snapshot test using the `snapshot` pytest fixture. The first run creates a snapshot file, and subsequent runs verify the data against it. The `--snapshot-update` flag is crucial for updating snapshots when expected data changes.
Review the official v5.0.0 release notes thoroughly. Update usage of `SnapshotAssertion` directly (e.g., `assert value == snapshot` instead of `snapshot.assert_match(value)`). Re-evaluate custom serializers and extensions.
Ensure your `requirements.txt` or `pyproject.toml` specifies `syrupy` instead of `pytest-syrupy`. Uninstall `pytest-syrupy` and install `syrupy`.
Run your tests with `pytest --snapshot-update` or `SYRUPY_UPDATE_SNAPSHOTS=1 pytest`. Be mindful of reviewing changes before committing updated snapshots.
Use the `pytest --snapshot-dirname my_custom_dir` command-line option, or configure a custom `PathResolver` if you need more complex logic. As of v5.0.0, `--snapshot-dirname` is available.
Install Syrupy using pip: `pip install syrupy`
Install the library using pip: `pip install syrupy`
Use a different snapshot extension, such as `syrupy.extensions.amber.AmberExtension`, or extend `syrupy.extensions.json.JSONExtension` with a custom serializer for the problematic type (e.g., `datetime.isoformat()`).