--

RTL recommends that you avoid using test ids, and instead use things that are visible to the user, like text or labels. I personally wouldn't worry about coupling to RTL, since if you have to change how you're rendering/querying the DOM in tests, you have bigger issues.

I do like the idea of creating a default component that provides all the props tho.

--

--

Amy Blankenship
Amy Blankenship

Written by Amy Blankenship

Full Stack developer at fintech company. I mainly write about React, Javascript, Typescript, and testing.

Responses (2)