Loading…
A short voice session: one question, one follow-up, then instant feedback — up to 5 minutes.
Test behaviour the way users experience it: find elements by role and label, interact through user events, and assert on visible output rather than internal state.
React Testing Library avoids testing implementation details such as state variables or component instances. Query elements with getByRole, getByLabelText or getByText, which also checks that the UI is accessible. For the form, render it, mock the network layer for example with MSW to return an error, type into the fields with user-event, click the submit button, and await findByRole("alert") or the error text. Using findBy or waitFor handles the asynchronous update. Such a test keeps passing when you refactor internals but fails if users would see a broken behaviour.