-
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
General thoughts for discussion on the framework #44
Comments
All these seem feasible to me.
Potentially the Regarding JSONassert - we would need to refactor so that the Verifier is aware of the Kind of what I'm getting at is to support this that snapshot perhaps needs to be aware of the comparitor. This may need some through and might need to be also serialized into the snapshot itself. I think we can include a few very basic reporters in core and others can be their own separate projects.
So there is a conflict of concerns here
I wonder if there is a way we can achieve this without inhibiting the end user too much while they work locally. Perhaps a
And yeah - Happy to review PR's. Thanks |
Do we need the verifier to be aware of the entire serializer or would it be enough if it's aware of the 'type' of serializer. Would it make sense to have an enum of serializer types and pass just the enum value to the verifier ? That way we don't have to store the className or any reference in the snapshot and just rely on the existing expect().json() or expect().text() call to make the distinction of what verifier to use. What do you think ?
I'll work on the PR this weekend and have something ready for you to look at sometime next week. |
Otherwise - we can consider header meta information in the snapshot itself:
Something like
|
BTW I'm now realising there is a difference between the
|
Ah I see what you're getting at. I agree and I think we're on the same page now. Will let you know once I have some updates on the PR. |
#46 Submitted a draft pull request for discussion. Let me know if I'm off on anything. I'll address them on subsequent commits. |
Have merged item 3 (lazy snapshots). |
Thanks for your work on this @juja0. Will do a release shortly. |
Released |
Great. Thanks mate. |
Thank you for this excellent library.
I was using an in-house utility for snapshot testing which was pretty much identical to this but since this one is open source, I'm moving to this one. There are a few things that I do miss from my old framework though so I wanted to have a general discussion about whether or not they can be incorporated in this library. These are not 'issues' per se so I'm listing them here. I can create separate issues for these if required or once we make a decision on them.
Json comparison is currently being done using text equals and the report generated using diffutils, which sometimes highlights differences in newlines and whitespaces. There may be cases where this might be preferred but I was wondering if it's possible to have a plug-in comparator and report generator. This gives users the option to use something like https://github.com/skyscreamer/JSONassert for json comparison or regular junit/assertj for assertions (this is nice because IDEs can then show a diff natively)
The default behaviour when a snapshot doesn't exist should probably not be to create one automatically. This may be a problem in CI/CD environments because if a test class is refactored and moved to a different package and if the snapshot is not moved, the test will always keep passing on CI/CD even if there are breaking changes.
Would also be nice to create the snapshot file lazily if it doesn't exist. We use junit jupiter's meta-annotation support to create a single test annotation which configures sane defaults for all tests and that includes SnapshotExtension. This single annotation is then used for all tests instead of each test having a huge list of annotations (especially for spring based tests). This works now but it ends up creating a bunch of empty snapshot files since all tests now use the snapshot extension but don't actually use the 'expect' call.
Let me know what you think about these. I'll be happy to submit a PR for the changes we agree upon.
The text was updated successfully, but these errors were encountered: