reactjs - 没有测试文件,但 NextJs 仍然显示这个`测试时,导致 React 状态更新的代码应该被包装到 act(...) 中:`
问题描述
我想知道这个错误消息是从哪里来的。我扫描了所有与测试相关的文件。**.test.tsx、**.test.js 和 *.spec.tsx 等。知道为什么即使项目中没有测试也会出现这种情况。
笔记:
- 在标记重复之前,请注意,我的项目中没有任何测试文件。
- 我已经针对关键字扫描内联测试用例,
it, describe, test)
但没有运气
When testing, code that causes React state updates should be wrapped into act(...):
act(() => {
/* fire events that update state */
});
/* assert on the output */
This ensures that you're testing the behavior the user would see in the browser.
解决方案
推荐阅读
- push-notification - 代号一推送通知失败
- powershell - 使用 .txt 文件填充 Powershell 脚本
- javascript - 如何使用 Vue 对全局变量做出反应?
- raku - 模块名称匹配
- json - 将 JSON 对象分配给 ReactJS 中的样式属性是否会使对象不可配置
- amazon-s3 - 是否可以在 fluentd s3_output 中设置主机
- firebase - Firestore 如何保存日期?
- click - 从主机外壳向 VirtualBox VM 发送鼠标或触摸事件?
- git - 如何在拉取请求之前合并冲突?git pull 已经是最新的了
- python - Mat plot lib 绘制图像而不是保存(facebook Detectron 代码)