4 ms·
Snapshot testing is useful for catching regressions and nothing else. It’s better than nothing, and in some cases is the only thing you can do if you don’t prop
by true_religion 7y ago
Snapshot testing is useful for catching regressions and nothing else. It’s better than nothing, and in some cases is the only thing you can do if you don’t properly understand what all the inputs and outputs of a system mean.
For example if working with a large legacy codebase, it’s important to maintain previous functionality and only change it if you can rationalize why. People and other systems might be relying on something that’s a bug, or a side effect that’s not obvious.
If you don’t do this, then you can either choose to have no tests, or have to tear down the whole system to understand it.
- pydry 7y ago>Snapshot testing is useful for catching regressions and nothing else. Visualizing and eyeballing snapshots in behavioral tests is a highly effective way of catching bugs and defining behavior (edit code - run test - verify output is correct, if it is, lock it down). I find them to be vastly more effective and cheaper to build than unit tests even on greenfield code bases.
- diggan 7y agoThe painful part is "verify output is correct" which only the person who initially did the test, can actually say it's correct or not. If a new person joins the codebase and sees that a snapshot is now different, how they know what's correct or not? What I've seen in the wild is 1) talk with the person who authored the test or 2) just say yes and move on.
- Tyr42 7y agoI mean you should have the context of your change right. If you're submitting a change to reduce the margins on everything, you should expect to need a new snapshot. If you're are doing a pure refactor of your css, you shouldn't see a change. Unless your css rules are order dependent and now you caught that.
- pydry 7y agoMaking it the snapshot behavior based and comprehensible to the product owner helps with that.
- dllthomas 7y agoIn some contexts, snapshots can also serve as documentation. Making (some, chosen) outputs visible to git can be pretty cool.