getByTestId
, or which query should I use?- query cheatsheet
- API reference for all queries
- regular old jest matchers: https://jestjs.io/docs/en/expect#expectvalue
jest-dom
custom matchers: https://github.com/gnapse/jest-dom#custom-matchers- footguns like
toContainHTML
: https://github.com/gnapse/jest-dom#tocontainhtml
- firing events
- full list of
dom-testing-library
events
- full list of
- input event
user-event
- can't test styles on hover (github issues)
- While developing, run
npm run test -- -f ${componentName} --watch
- Tests re-run on save = instant feedback
- When we want to view more in-depth coverage reports, run
npm run test
(need to overwrite partial coverage that's generated when watching a single file)