All jobs / Frontend / web developer / Testing

Frontend / web developer interview question · 1–3 years

How do you assert a login button in React Testing Library?

The strongest answer

Find by role and name — getByRole('button', { name: /log in/i }) — not test-id-first or snapshot-everything

Why it works

RTL's point is the user tree: roles and names catch a11y holes and survive refactors.

What a good answer covers

Answers that fall short

Who gets asked this

More Testing questions