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 assertion 順序。確認升級後的 timing 行為,並記錄為什麼等待渲染出的錯誤並不能證明基於 effect 的 logging 呼叫已經完成。
由索引模型根據 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 於 79 天前認領,目前沒有進行中的 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 於 305 天前認領,目前沒有進行中的 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
-
change request evaluating
難度 2/5 1-3 小時 新手友好度 72/100
sindresorhus/eslint-plugin-unicorn#3907 ·
維護者通常 1 天內回覆
-
Android bug feature/error-tracking react-native team/error-tracking
難度 2/5 1-3 小時 新手友好度 72/100
PostHog/posthog-js#5310 · 1 則留言 ·
維護者通常 1 天內回覆
-
Add Prettier and a format-check CI job可能已有人在做 @ezekielnathaniel070-ai 今天認領。 未關閉backend frontend good first issue Stellar Wave
難度 2/5 1-3 小時 新手友好度 75/100
OlaGreat/starbound-realms#98 · 1 則留言 ·
-
app request good first issue help wanted self-hosted app
難度 2/5 1-3 小時 新手友好度 75/100
Secra-Solutions/Conector#15 ·
-
Complexity: See issue making label epic good first issue Issue Making: Level 1 P-Feature: Project Info and Page role: back end/devOps role: front end size: 0.25pt time sensitive
難度 2/5 1 小時以內 新手友好度 65/100
維護者通常 1 天內回覆