What is component testing?
Component testing is checking individual UI components in isolation to make sure they render correctly, handle data and respond to user actions. This approach lets you find errors at the earliest level, before the component is integrated into larger screens and scenarios.
The task of component testing
Guarantee that a specific component:
- renders with the correct content
- correctly changes state on actions (click, input, etc.)
- correctly displays different input data (props, state)
- calls the right functions or events
What is usually checked
- correct text, markup and elements in the DOM
- reactions to user actions
- state changes
- correct output for different props
- correct rendering in different states (loading, error, empty, success)
Where it is used
- React
- Vue
- Angular
- Any modern UI frameworks
Summary
Component testing provides reliability and predictability of the UI at the level of the interface's building blocks, before these blocks are assembled into full user scenarios.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.