Unable to getByRole figure with accessible name / description in figcaption
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 52/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- javascript, react
- 领域
- testing
调研方向
首先,使用 accessible name 和 description 选项,通过 screen.getByRole 重现报告中的 figure 标记。跟踪 getByRole 对 figure 和 figcaption 语义的处理,然后验证查询是否找到了具有预期 accessible name 或 description 的 figure。
由索引模型根据 Issue 内容生成。
描述
@testing-library/reactversion: 16.3.0- Testing Framework and version: jest 30.0.5
- DOM Environment: jest-environment-jsdom 30.0.5
Relevant code or config:
<figure>
<figcaption>Foo</figcaption>
<ul>
<li>Bar</li>
</ul>
</figure>
What you did:
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
As per:
https://www.w3.org/WAI/ARIA/apg/practices/names-and-descriptions/
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.
- 主要语言
- JavaScript
- 星标
- 19.7k
- 派生
- 1.2k
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
testing-library/react-testing-library 的其他 Issue
-
fireEvent.select does not wrap its automatic native focus in act可能已有人在做 @sergioperezcheco 于 8 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 88/100
-
bug: calling configure() without reactStrictMode resets it to undefined, silently disabling strict mode可能重新可做 @suhailopensource 于 78 天前认领,目前没有进行中的 PR。 未关闭
难度 2/5 1-3 小时 新手友好度 35/100
testing-library/react-testing-library#1466 · 1 条评论 ·
-
难度 4/5 3-5 天 新手友好度 30/100
testing-library/react-testing-library#1459 · 2 条评论 ·
-
perf: optimize container lookup with early exit可能重新可做 @Ch-Abhinav-Chowdary 于 304 天前认领,目前没有进行中的 PR。 未关闭
难度 1/5 1 小时以内 新手友好度 35/100
testing-library/react-testing-library#1430 · 1 条评论 ·
-
`fireEvent.mouseEnter` does not forward `relatedTarget` (relatedTarget is the window instead)可能已有人在做 @swarnim02 于 322 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 55/100
查看 testing-library/react-testing-library 的全部 Issue
相似的 Issue
-
documentation
难度 2/5 1-3 小时 新手友好度 74/100
andromarces/agent-loops#886 ·
维护者通常 1 天内回复
-
bug effort:low model:light plan planner:gpt-6-1-sol tests
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
B: visual
难度 2/5 1-3 小时 新手友好度 65/100
FreeTubeApp/FreeTube#9929 ·
维护者通常 1 天内回复
-
status: in triage type: bug
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
supabase/supabase-js#2768 ·
维护者通常 1 天内回复