post-upgrade, unexpected assertion failures on error-handling function calls (includes repro)
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- javascript, react
调研方向
从链接的 CRA 复现开始,检查 issue 中所示的 render、findByText 和 mockLog 断言顺序。确认升级后的时序行为,并记录为什么等待渲染出的错误并不能证明基于 effect 的日志调用已经完成。
由索引模型根据 Issue 内容生成。
描述
@testing-library/reactversion: 13.4.0- Testing Framework and version: [email protected]
- DOM Environment: [email protected]
- node: 16.14.2
- react: 18.2.0
Relevant code or config:
render(<App />);
await screen.findByText('Failed!');
//assertion fails unless we `waitFor` it
expect(mockLog).toHaveBeenCalledWith('kaboom!')
What you did:
Upgraded existing application to react 18+ and RTL 13+.
What happened:
A number of tests starting failing assertions after upgrading.
In this case, the component is rendered with a simulated fetch failure. The component renders a child component that is responsible for error presentation and minor logging (in an effect hook). The test assertion on the logging function call fails unless it is awaited.
Reproduction:
I was able to reproduce the issue with a simple CRA repo, here: https://github.com/trv-wcaneira/fetch-err-waitfor-mcve
Problem description:
Pre-upgrade, it was sufficient to await the error message text rendered by the child component. Now it seems additional waiting is needed, and before I plaster waitFors all over our tests 😄, I'd just like to understand why.
Suggested solution:
I could obviously change all the tests to waitFor the logging function call, but would like to understand the change in behavior.
- 主要语言
- 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 于 9 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 88/100
-
bug: calling configure() without reactStrictMode resets it to undefined, silently disabling strict mode可能重新可做 @suhailopensource 于 80 天前认领,目前没有进行中的 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 于 306 天前认领,目前没有进行中的 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 于 323 天前认领。 未关闭
难度 3/5 1-2 天 新手友好度 55/100
查看 testing-library/react-testing-library 的全部 Issue
相似的 Issue
-
enhancement
难度 2/5 1-3 小时 新手友好度 67/100
维护者通常 1 天内回复
-
enhancement good first issue
难度 2/5 1-3 小时 新手友好度 76/100
SasanLabs/VulnerableApp#836 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 76/100
keyxmakerx/Chronicle#1469 ·
维护者通常 1 天内回复
-
Connection.prototype.bulkWrite() with ordered: false resolves null when a write fails可能已有人在做 @maxymlyskov 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
Automattic/mongoose#16601 ·
维护者通常 2 天内回复
-
sandbox-vercel: persistent: false is dropped for live sandboxes created from a template, so every stop writes a snapshot可能已有人在做 @jvg123 今天认领。 未关闭factory-active task-identify-harness-labels-done task-identify-issue-type-done
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复