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

Ideas for normalizing snapshots #12

Open
skuzzle opened this issue Jan 10, 2022 · 0 comments
Open

Ideas for normalizing snapshots #12

skuzzle opened this issue Jan 10, 2022 · 0 comments

Comments

@skuzzle
Copy link
Owner

skuzzle commented Jan 10, 2022

Random data within the snapshot is a huge problem and might need a lot of mocking or manual post processing of the actual test result in order to be able to reliably use snapshot assertions. This is kind of in the way of our design goal of "making it super simple to get a lot of assertions for free".

Few points for the discussion:

  • At what level should normalization be applied? Normalize the actual test result before serializing, normalize the snapshot after normalization (string based), do not normalize the persisted data but normalize "on the fly" during comparison?
  • Adding to that, should we provide reflection based normalizing for actual objects?
  • Should we provide serialized structure (json/xml) based normalization for serialized string data (XPath, Json Path)?

Either way, I still think that normalizing the data is an anti-pattern. As stated in the readme, you should design your code in way that you can provide mocks returning deterministic instead of reandom data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant