#testing
- Unit test small modules of code.
- Mock all dependencies with exceptions (React, Alm.queryBuilder)
- Small snapshot tests
- Make sure stubs are called if you want side effects of components
- Avoid testing react internals
- Tests how the pieces fit together
- Mocks API requests
- tests multiple units of code
#work #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
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.