React Component Testing
Test what the user sees, not implementation details.
render(<Component />)from@testing-library/react.- Query by accessible role:
screen.getByRole('button', { name: /save/i }). - Drive interactions with
userEvent, then assert on the resulting DOM. - Avoid
container.querySelectorand snapshot-everything tests — they break on refactors.
Prefer findBy* for async UI and getBy* for content that is already present.