You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unable to getByRole figure with accessible name / description in figcaption #1417
What trying to get hold of the figure element using:
const figure = screen.getByRole("figure", { name: "Foo" });
or
const figure = screen.getByRole("figure", { description: "Foo" });
or
const figure = screen.getByRole("figure", { name: /Foo/ });
or
const figure = screen.getByRole("figure", { description: /Foo/ });
What happened:
ShadowDOMTestingLibraryElementError: Unable to find an element with the role of: figure
Reproduction:
Problem description:
Unable to get figure using accessible name / description in figcaption
Like with table elements, if a figure is not named using aria-label or aria-labelledby, the content of the figcaption element will be used as the accessible name. However unlike table elements, if the figcaption element is not used for the name, it does not become an accessible description unless it is referenced by aria-describedby. Nevertheless, assistive technologies will render the content of a figcaption regardless of whether it is used as a name, description, or neither.
Activity
karesztrk commentedon Jun 1, 2026
According to Adrian Roselli
<figcaption>shouldn't give accessible name. But MDN says it the other way around:Huaian666 commentedon Jun 6, 2026
finally something that doesn't try to do everything. does one thing, does it well, gets out of your way. respect.
Huaian666 commentedon Jun 6, 2026
been using this at work for a few weeks. handles edge cases that caught us off guard with other tools. really well thought out.
beanscg commentedon Jun 9, 2026