Skip to content

Instantly share code, notes, and snippets.

@gravitinos
Last active October 11, 2018 16:32
Show Gist options
  • Select an option

  • Save gravitinos/040fd03989df2edfa670a5d016301f9a to your computer and use it in GitHub Desktop.

Select an option

Save gravitinos/040fd03989df2edfa670a5d016301f9a to your computer and use it in GitHub Desktop.

Jest

#work #testing

Snapshot testing

Effective Snapshot Testing – kentcdodds Important points wherer snapshots fail

  • Intention
  • generated (devs don't pay attention)
  • false negatives?
  • Fails even if it still "works"

Avoid

  • huge snapshots

Utilities

  • eslint-plugin-jest called “no-large-snapshots”
  • snapshot-diff

Reflection on Snapshot

Snapshot testing still feels pretty useful to me, but it’s apparent that we can abuse this tool. This tool does not enforce much, which makes it dangerous. The no large snapshots seems to be something we should introduce ASAP. We should also use snapshot diff while we can, and make sure our components are small. This makes me question if we should unit test things like Page.js’s. It feels like they should be integration.

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