{"id":1739,"library":"syrupy","title":"Syrupy","description":"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.","status":"active","version":"5.1.0","language":"en","source_language":"en","source_url":"https://github.com/syrupy-project/syrupy","tags":["pytest","testing","snapshots","developer-tools","fixtures"],"install":[{"cmd":"pip install syrupy","lang":"bash","label":"Install Syrupy"}],"dependencies":[{"reason":"Syrupy is a pytest plugin and requires pytest to function.","package":"pytest","optional":false},{"reason":"Optional for enhanced diff output in the console.","package":"rich","optional":true}],"imports":[{"note":"The 'snapshot' object is a pytest fixture, not a direct Python module import for basic usage. For type hinting, you might import `SnapshotAssertion`.","wrong":"import syrupy.snapshot","symbol":"snapshot","correct":"def test_example(snapshot):\n    # snapshot is a pytest fixture provided by syrupy"},{"note":"Useful for type hinting the 'snapshot' fixture in your tests, e.g., `def test_example(snapshot: SnapshotAssertion):`","symbol":"SnapshotAssertion","correct":"from syrupy.assertion import SnapshotAssertion"}],"quickstart":{"code":"import pytest\n\ndef test_data_snapshot(snapshot):\n    data = {\n        \"id\": 123,\n        \"name\": \"Example Item\",\n        \"details\": [\n            {\"key\": \"value1\", \"status\": \"active\"},\n            {\"key\": \"value2\", \"status\": \"inactive\"}\n        ]\n    }\n    assert data == snapshot\n\n# To run this test:\n# 1. Save as `test_snapshot.py`\n# 2. Run `pytest` in your terminal\n# 3. On the first run, a snapshot file will be created (e.g., `__snapshots__/test_snapshot.ambr`).\n# 4. On subsequent runs, it will compare against the snapshot.\n# 5. To update snapshots, run `pytest --snapshot-update`","lang":"python","description":"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."},"warnings":[{"fix":"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.","message":"Version 5.0.0 introduced significant breaking changes, including API changes for `SnapshotAssertion`, removal of `assert_match`, and a license change from MIT to Apache 2.0. The `pygments` dependency was also removed.","severity":"breaking","affected_versions":"5.0.0 and later"},{"fix":"Ensure your `requirements.txt` or `pyproject.toml` specifies `syrupy` instead of `pytest-syrupy`. Uninstall `pytest-syrupy` and install `syrupy`.","message":"The project was renamed from `pytest-syrupy` to `syrupy` in version 4.0.0. Users upgrading from older installations (pre-4.0.0) will need to update their `pip install` commands and potentially package references.","severity":"breaking","affected_versions":"4.0.0 and later"},{"fix":"Run your tests with `pytest --snapshot-update` or `SYRUPY_UPDATE_SNAPSHOTS=1 pytest`. Be mindful of reviewing changes before committing updated snapshots.","message":"Snapshots will fail if the asserted value changes. To update snapshots to reflect new expected output, you must explicitly run pytest with the `--snapshot-update` flag or set the `SYRUPY_UPDATE_SNAPSHOTS` environment variable.","severity":"gotcha","affected_versions":"All versions"},{"fix":"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.","message":"Snapshot files are stored in `__snapshots__` directories by default, relative to the test file. Changing the default behavior (e.g., storing snapshots in a different directory) requires using the `--snapshot-dirname` option or a custom `PathResolver`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}