How do I find out the aria role of MUI components for RTL querying?

Viewed 336

I've just started migrating from enzyme to react testing library on my project that uses material-ui. From what I understand, RTL queries the dom and the recommended query methods is by aria role. How do I query something like MUI's Typography, Box, or API components like Dialog? Can anyone point me to how I can get the aria roles or how to query Mui components?

1 Answers

I also faced the same issue a few months back. I've started searching for that element in DOM and then checking for some property like test_id or role or label in DOM. Else you check check github of Material UI they must have pushed test cases as well for reference.

Related