Discussion about this post

User's avatar
Mike's avatar

Snapshot testing is a good tactic for adding tests to existing (typically legacy) code. Especially if you’re about to refactor some confusing code where you know it works, but how it works is obfuscated.

You can exercise the current behavior, get a snapshot of the results, then refactor the code to make it clean and clear. You know it still does the same thing because of the snapshot.

You’ll learn more about what the code does during this progress so you can now write informed tests.

Expand full comment
Tomas Malmsten's avatar

This sounds a lot like approval testing too me. Are they the same? If not, what is the difference?

Expand full comment
12 more comments...

No posts