Skip to content
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

Snapshot testing. #777

Closed
sksamuel opened this issue May 22, 2019 · 8 comments
Closed

Snapshot testing. #777

sksamuel opened this issue May 22, 2019 · 8 comments
Labels
enhancement ✨ Suggestions for adding new features or improving existing ones. stale 🏚️ Issues that were lost to time and are no longer up-to-date

Comments

@sksamuel
Copy link
Member

Maybe some inspiration here:
https://github.com/Karumi/KotlinSnapshot

@LeoColman LeoColman added the enhancement ✨ Suggestions for adding new features or improving existing ones. label May 22, 2019
@sksamuel
Copy link
Member Author

@sksamuel sksamuel reopened this May 31, 2020
@sksamuel sksamuel added this to the 4.2 milestone Jun 27, 2020
@sksamuel sksamuel removed this from the 4.2 milestone Jul 17, 2020
@krzema12
Copy link

krzema12 commented Feb 8, 2023

@sksamuel could you share a reason why you decided to not imolrment it in kotest?

@Kantis Kantis reopened this Feb 9, 2023
@Kantis
Copy link
Member

Kantis commented Feb 9, 2023

Perhaps we could list some desired use-cases here? I think it would be nice to be able to use various matchers for snapshot testing.. (For instance testing JSON equality, partial JSON equality, testing JSON Schema and so on)

Sshould we have explicit methods for every matcher, or should snapshot testing take a matcher as argument?

@krzema12
Copy link

@Kantis I thought about the very basic use case in scope of the first iteration, which is dumping an object/collection and then exact comparison. Other marchers may be a good idea in the next iterations to enable checking of structures that contain some non-determinism, e. g. various order of elements - is that your intent?

@Kantis
Copy link
Member

Kantis commented Feb 12, 2023

Sounds good. Still, as can be seen in the linked tool for snapshot testing, there's a lot of nuance. (How do we serialize? Should private properties matter? How can the user tweak these serialization options?)

I also think there's a possibility here to add really good tooling. A previous workplace used snapshot testing, and if you ran a snapshot test in an interactive environment (e.g. if it detected intelliJ) it would pull up a diff view of the failure and let you choose whether to overwrite the snapshot interactively. I think that would be a really neat feature to add along the line :)

I've also been mulling whether we can somehow make matchers snapshot-aware. E.g. if we somehow added a middleware in testing where you could call a Matcher<T> with a Snapshot<T> which would load the snapshot and test it, and handle failures, overwrites, interactivity, etc..

@stale
Copy link

stale bot commented Mar 18, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale 🏚️ Issues that were lost to time and are no longer up-to-date label Mar 18, 2023
@stale stale bot closed this as completed Apr 2, 2023
@nedtwigg
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ✨ Suggestions for adding new features or improving existing ones. stale 🏚️ Issues that were lost to time and are no longer up-to-date
Projects
None yet
Development

No branches or pull requests

5 participants