Releases: syrupy-project/syrupy
Releases · syrupy-project/syrupy
v4.0.5
v4.0.4
v4.0.3
v4.0.2
v4.0.1
v4.0.0
4.0.0 (2023-02-02)
NOTE: You will need to regenerate snapshots if using the default Amber serializer. Run
pytest --snapshot-update
.
Performance
- Writes no longer occur at assertion time, but are instead queued to happen at the end of the pytest session. This defers IO operations to the end of the test run, however it does increase memory usage. If this presents an issue, we can look at providing an opt-out mechanism for deferred writes. This should also improve pytest-xdist compatibility somewhat.
Breaking Changes
Requirements
- Min. python version updated to 3.8.1. Since it's possible not everyone will be able to upgrade to Syrupy v4 because of the increase minimum python version, we will consider backporting critical bugs and security vulnerabilities on request (create a GitHub issue).
- Min. pytest version updated to 7.0.0.
Bug Fixes
- Removed legacy path usage to support no:legacypath. (#677)
Serializers
- JSON: None is now serialized as
null
. (#622) - Amber/JSON: Key order of OrderedDicts are now preserved. (#618)
- Amber: It's now possible to extend the default amber serializer to support numerical sorting of snapshot test cases. An experimental sorted data serializer is available. For an example of how to enable sorting, see test_amber_sort.py. Note that this currently has performance issues which is why it is not the default behaviour. (#657, #683)
- Amber: A new "# serializer version: 1" line is now written to the top of each ambr file. Adopters of syrupy v4 will receive a message telling the user to regenerate snapshots. As with any major version update, you'll need to run
pytest --snapshot-update
. This version marker is being placed to make it simpler to support multiple versions of the amber serializer, and thus rollout what has previously been considered breaking changes, without queueing for a major version update.
Extensions API
- For developers of custom Syrupy extensions, there are a number of changes to the public API of the various extension abstract classes:
- pre/post read/write hooks have been removed. If you were using these hooks, please open a GitHub issue and we'll consider re-adding them (they had little usage and introduced maintenance complexity).
- test_location is no longer passed to the constructor of extensions. Instead, it is now an explicit argument of most extension methods.
- file_extension is now a class property rather than a property instance method.
- dirname and various other filename related properties have been converted to class methods.
- Renamed DataSerializer to AmberDataSerializer.
- Serializers may now throw a TaintedSnapshotError which will tell the user to regenerate the snapshot even if the underlying data has not changed. This is to support rolling out more subtle changes to the serializers, such as the introduction of serializer metadata.