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

Using snapshot testing with Jest - Pros and Cons #9

Open
einatnielsen opened this issue Dec 2, 2019 · 1 comment
Open

Using snapshot testing with Jest - Pros and Cons #9

einatnielsen opened this issue Dec 2, 2019 · 1 comment

Comments

@einatnielsen
Copy link
Contributor

Cons:

  • Failures are hard to understand (It’s often hard to see what changed by looking at the snapshot failure diff)
  • We tend to update snapshots without thinking
  • Easy to commit snapshots with bugs (since we usually don’t read these files carefully)
  • Coupling with low level modules (if you don’t use shallow rendering)
  • A false sense of security (Snapshots offer no guarantees that component appearance or behavior is correct)
  • FB recommends using more specific assertions than using snapshots here
@MatanBorenkraoutNielsen
Copy link
Contributor

Cons:

  • Snapshot testing is actually a big implementation detail. It saves component names, prop names and much more that will probably break on every refactor.
  • Snapshot False negatives quickly erode the team's trust in a test to actually find bugs and instead come to be seen as a chore on a checklist, also, most developers will just update the snapshot and get it over with.

Pros:

  • Inline snapshot is a good tool, using it to check equality of an object, classes or any small object can be useful and added to the specific test (not added as a different file).

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

No branches or pull requests

2 participants