
Overview
When using getByRole
from react-testing-library to retrieve the component/element content, it should be quite straightforward, but when the component/element is wrapped with the Tooltip component from Material UI, something weird happen: getByRole
can only get the content of the tooltip rather than the component/element content. This article is going to explain why such issue happen and how to fix it.