@testing-library/react version: 11.2.7
- Testing Framework and version:
jest 26x || 27x
- DOM Environment: 'jsdom'
16.x
Relevant code or config:
Source: https://testing-library.com/docs/queries/bytitle/
const Test = () => (
<>
<span title="Delete" id="2"></span>
<svg>
<title>Close</title>
<g><path /></g>
</svg>
</>
);
VS
const Test = () => (
<>
<span title="Delete" id="2"></span>
<svg>
<g>
<path>
<title>Close</title>
</path>
</g>
</svg>
</>
);
What you did:
render(<Test/>);
screen.getByTitle('Close');
What happened:
First Component - ✅
Second Component - ❌
TestingLibraryElementError: Unable to find an element with the title: Close.
Problem description:
Testing library cannot find Close because it's not a direct child of svg.
Suggested solution:
I should be able to find Close even if it's not a direct child of svg.
@testing-library/reactversion: 11.2.7jest26x || 27x16.xRelevant code or config:
Source: https://testing-library.com/docs/queries/bytitle/
VS
What you did:
What happened:
First Component - ✅
Second Component - ❌
Problem description:
Testing library cannot find
Closebecause it's not a direct child ofsvg.Suggested solution:
I should be able to find
Closeeven if it's not a direct child ofsvg.