Bug: getByRole('paragraph') doesn't work
See original GitHub issuetest(
'getByRole("paragraph")',
withBrowser.headed(async ({ utils, screen }) => {
await utils.injectHTML(`<p>This is a paragraph</p>`);
// throws
const paragraph = await screen.getByRole('paragraph');
})
);
The paragraph
role is added automatically to the element by the browser. It shows up in the accessibility tree in Chrome DevTools. But the above fails.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
getByRole query for paragraph not working during React testing
getByRole uses the HTML role of different elements. Paragraph is not a valid role, that's why your query doesn't work.
Read more >getByRole query for paragraph not working during React ...
getByRole uses the HTML role of different elements. Paragraph is not a valid role, that's why your query doesn't work. You can read...
Read more >ByRole | Testing Library
getByRole ('button') would only return the Close dialog -button. To make assertions about the Open dialog -button you would need to use ...
Read more >getByRole should support fallback roles · Issue #411 - GitHub
This is what I was trying to say: An element doesn't have multiple roles in a given environment. It has a single one....
Read more >Making sure you're using the correct query - Tim Deschryver
The short answer to "which query should I use", is most of the time the *ByRole query. There are some cases that this...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think this role was added in the latest aria spec which isn’t widely supported by tooling/browsers yet. I could be misremembering though, I will look into it
Oh now I am noticing that aria 1.1 is not the latest version, aria 1.2 is the latest published version. 1.2 lists the paragraph role: https://www.w3.org/TR/wai-aria-1.2/#paragraph. It shows
<p>
as a “related concept” which I don’t know if that means it is applied automatically. The HTML-aria spec still says<p>
has no implicit role: https://www.w3.org/TR/html-aria/#el-p