ByRole have inconsistent results (getting h2 instead of button)
shadowvzs opened this issue · comments
version (@testing-library/react): 12.1.5
renderUtils = render(<MyComponent/>);
renderUtils.getByRole('button', { name: /^Confirm address$/i, exact: true });
TestingLibraryElementError: Found multiple elements with the text: Confirm address
Here are the matching elements:
Ignored nodes: comments, script, style
<h2>
Confirm address
</h2>
Ignored nodes: comments, script, style
<button type="button">
Confirm address
</button>
The expected results would be if only 1 button have with this text then doesn't get this error, since h2 (header 2) isn't a button.
[EDIT] sorry by bad, there was a getByText as well