I can see the value of testing business logic and custom components, but I'm less sure about ordinary pages and third-party UI components. What kinds of UI behavior do you test, and at what level?
Do you write unit tests for UI components?
Answers
I'd test the behavior your application owns. For a stateful component, that might mean checking state transitions, conditional rendering, calculations, formatting, and whether an action triggers the right result. Basic accessibility checks can be useful too.
A test that only proves a library button displays the label passed to it usually isn't buying much. If you've copied or heavily modified a component, though, its behavior has become your responsibility and a regression test may make sense.
Reply to this answer
Use a few levels. Unit test the complicated logic, component test the custom behavior, and keep a small set of browser smoke tests for critical user journeys. A login test that goes through the page and authentication system is closer to an end-to-end test than a unit test.
Reply to this answer
Permissions are a good reason to test the UI. Check that each role sees the actions it should and that the relevant flows work. But hiding a button isn't authorization, so also test protected API routes directly with roles that should and shouldn't have access.
Reply to this answer
Visual tests can be worth considering when appearance matters. Screenshot comparisons let you review what changed visually, while large DOM snapshots can produce noisy failures that are easy to dismiss.
With mocked network responses, screenshots can cover different UI states without running every case through a full end-to-end flow. I'd still keep a few smoke tests for the real journey.
Reply to this answer
There's also a time budget to consider. A small team using mostly standard components might get more value from testing core logic and walking through the UI than from building a large component test suite. Focus automated coverage on the failures that would hurt the app most.
Reply to this answer
Add your answer
Answers are reviewed before publication.
_d47!ferrygauge.8:
That split helps. The UI check covers what the user is offered, while the API check covers whether the restriction is actually enforced.