react-testing-library - 传递元素时,waitForElementToBeRemoved 超时
问题描述
我正在尝试waitForElementToBeRemoved
仅使用一个元素,但 Jest 正在超时。当我传入一个函数时,它可以工作。
我对这个特性的理解是它应该能够接受一个元素:https ://github.com/testing-library/dom-testing-library/pull/460
我验证了我的应用程序正在使用@testing-library/dom@7.8.0。
这是代码:
// doesn't work
await waitForElementToBeRemoved(screen.getByText("Loading..."));
// works
await waitForElementToBeRemoved(() => screen.getByText("Loading..."));
知道我做错了什么吗?
解决方案
除了我之前的回答,我建议使用queryByText
:
await waitForElementToBeRemoved(screen.queryByText("Loading..."));
而不是getByText
:
await waitForElementToBeRemoved(screen.getByText("Loading..."));
推荐阅读
- reactjs - React-Bootstrap Navbar 不显示样式
- r - Rcpp:S4.slot() 的成本
- typescript - 强制接口字段的名称必须等于另一个字段的值
- git - 无分支推送 git commit
- node.js - docker container install -g 复制到其他容器
- xcode - Xcode10 错误:“iPhone 已拒绝启动请求”
- kernel - ESXi 中的审核服务?
- mysql - 无法根据销售额对商品进行排名,
- java - 如何在 IntelliJ IDEA 中列出所有未经测试的类?
- azure-devops - 如果我们只有一个团队,我们如何同时进行多个冲刺?