-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Give custom name to image snapshot file #555
Comments
Not possible at the moment, and there are some assumptions about filename for the PNG extension, however perhaps we can add some "name" field. |
If i understood correctly the lib currently uses the test function name as name for the png + the number of calls to
can we perhaps add would be happy to contribute in any case ^^ |
That logic happens here: https://github.com/tophat/syrupy/blob/e008935c052106d157196ca77415f4773a14f64a/src/syrupy/extensions/base.py#L79. You should be able to adjust it for a custom extension or for the PNG / single file extension. There might be assumptions around it in terms of discovering unused snapshots. Feel free to explore it, contributions welcome. This bit gets a bit tricky though. |
+1 for this feature. We have string string assertions that need to land in separate named files. As soon as that lands, we'll happily migrate off of snapshottest |
@danfrankj would the behaviour of overriding num_call as @Bendidi suggested be sufficient? I don't think we could easily support full control of the name (outside of a custom extension) due to challenges with snapshot discovery. |
The snapshot_name_suffix will hold an optional suffix to be used instead of index in the snapshot_name. The suffix will by default be formatted to be between brackets: "[<snapshot_name_suffix>]" Co-authored-by: Ouail Bendidi <ouail.bendidi@gmail.com>
🎉 This issue has been resolved in version 1.5.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
@iamogbz Looks like this github comment was posted by the dry run for the next branch ^. |
Hello I have some tests where I need to generate multiple snapshot images in the same test.
Is it possible to provide the target snapshot name file to
snapshot
when asserting the images are equal ?My use case:
It works as intended, but IMO the syntax is weird and magical, (we are basically testing 2 different things against the same object).
what I'm looking for / propose is to be able to set a custom filename for the snapshot if we want:
Thanks!
The text was updated successfully, but these errors were encountered: