Flaky Tests with user.type (missing characters)
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 48/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
- 技术栈
- javascript, react, typescript
- 领域
- frontend, testing-qa
调研方向
从提供的 DialogWithInput 复现和 user.type 调用开始,使用列出的 React Testing Library、Vitest 和 jsdom 版本。复现缺少字符的失败,与 { delay: null } 这一变通方案进行比较,并验证完整的 why-won't-you-type-this? 值能够可靠地输入,尤其是在类似 CI 的条件下。
由索引模型根据 Issue 内容生成。
描述
@testing-library/reactversion: 16.3.0- Testing Framework and version:
[email protected] - DOM Environment:
[email protected]
Relevant code or config:
import {
Dialog,
DialogBody,
DialogContent,
DialogSurface,
DialogTitle,
} from "@fluentui/react-components";
const DialogWithInput = () => {
return (
<Dialog open={true}>
<DialogSurface>
<DialogBody>
<DialogTitle>Flaky RTL Test MWE</DialogTitle>
<DialogContent>
<input type="text" />
</DialogContent>
</DialogBody>
</DialogSurface>
</Dialog>
);
}
describe("DialogWithInput", () => {
it("accepts long text", async () => {
const user = userEvent.setup();
render(<DialogWithInput />);
const textbox = await screen.findByRole("textbox");
await user.type(textbox, "why-won't-you-type-this?");
await waitFor(async () =>
expect(textbox).toHaveValue("why-won't-you-type-this?")
);
});
});
What you did:
I tested whether a user could correctly modify a textbox using await user.type(<textbox>, <text-value>). The textbox is embedded inside a simple Fluent UI v9 Dialog component.
What happened:
user.type did not type the full text-value leading to a test failure:
Expected the element to have value:
why-won't-you-type-this?
Received:
why-wo
Reproduction:
Repo: https://github.com/[mzietlow/flaky-rtl-tests
Stackblitz (although I did not try it on stackblitz): https://stackblitz.com/github/mzietlow/flaky-rtl-tests
Problem description:
Tests are flaky. Especially on CI, where user.type tends to produce even fewer characters.
Suggested solution:
user.type should type all characters.
I was able to pass { delay: null } as a temporary workaround, but that is not really a solution.
- 主要语言
- 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 于 2 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 88/100
-
bug: calling configure() without reactStrictMode resets it to undefined, silently disabling strict mode可能重新可做 @suhailopensource 于 72 天前认领,目前没有进行中的 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 于 298 天前认领,目前没有进行中的 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 于 315 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 55/100
查看 testing-library/react-testing-library 的全部 Issue
相似的 Issue
-
check:passed feeds:remove
难度 1/5 1 小时以内 新手友好度 65/100
iptv-org/database#37176 · 1 条评论 · 1 个 reaction ·
维护者通常 9 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
hawk-digital-environments/HAWKI#443 ·
维护者通常 1 天内回复
-
documentation v2
难度 2/5 1-3 小时 新手友好度 82/100
modelcontextprotocol/python-sdk#3662 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
feedback simulation workshop
难度 2/5 1-3 小时 新手友好度 66/100
githubnext/gh-aw-workshop#4370 ·
维护者通常 1 天内回复