-
Notifications
You must be signed in to change notification settings - Fork 16
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
Unexpected snapshot errors when snapshotting with lots of newlines #126
Comments
If you're curious for a test case, this is the commit that took me from failing to passing |
Thanks. I believe this is a bug introduced via the 4.X release. Will look into it. |
Before I figured out the trim() workaround I tried going back to 3.4.0 just in case, but that was broken for me too. |
@nedtwigg are you developing on Windows and your CI is running Linux? I feel this might be a line ending issue. Git checkout as |
Nope, dev on mac, CI on Linux. |
I can replicate this issue locally. It is indeed related to leading/trailing newline characters. It's due to the |
Fixed in 4.0.2 |
Regarding the lossless implementation - can you open a "Discussion" about it from the "Discussions" tab. I'm not too crash hot on the manipulation of the snapshot data either. I'm not sure how the above function will fix the issue because we still need an escape character (hence snapshot text will be modified) |
Thanks so much for the library! I'm a big fan of snapshot testing, I've been baffled that java doesn't have one, and I think the high-level design of yours is fantastic! When I first tried it I got stuck for a while. Here was the behavior I was seeing
I dug around and found this eventually
java-snapshot-testing/java-snapshot-testing-core/src/main/java/au/com/origin/snapshots/serializers/ToStringSnapshotSerializer.java
Lines 28 to 32 in 5330f07
And it so happens that I was snapshotting input that started and ended with lots of newlines. So I tried adding a trim() before I passed my data to you and that fixed it.
IMO, it's a big deal to mangle the snapshot data - that's the most sacred part of a snapshot library! I think it's really important to pick a lossless encoding function.
trim()
works well enough for me for now so I'm not going to take the time to contribute a PR, but I can offer up this little hunk of code that I've used in several projects for handling problems of this sort (lossless roundtrip encoding of text in text). Feel free to use it or take a different approach :)The text was updated successfully, but these errors were encountered: