reactjs - 在 reactjs 中使用 jest 编写单元测试时,对 MsalAuthenticationTemplate 的更新运行效果、错误
问题描述
我正在开玩笑地编写单元测试,我的单元测试正在运行,但我总是遇到错误。由于这个错误,它没有显示成功运行的覆盖率和测试描述
console.error
Warning: An update to MsalAuthenticationTemplate ran an effect, but was not wrapped in act(...).
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. Learn more at https://reactjs.org/link/wrap-tests-with-act
at MsalProvider (C:\XXXXXX\node_modules\@azure\msal-react\src\MsalProvider.tsx:25:31)
at ThemeProvider (C:\XXXXXX\node_modules\@material-ui\core\node_modules\@material-ui\styles\ThemeProvider\ThemeProvider.js:48:24)
at Provider (C:\XXXXXX\node_modules\react-redux\lib\components\Provider.js:21:20)
任何人都面临同样的问题并且有 MsalAuthenticationTemplate 的示例模拟吗?
解决方案
推荐阅读
- python - 将项目添加到列表列表 - Python
- powershell - 将一行的一部分携带到以下行Powershell
- spring - 如果 hashset 在多对多关系中手动创建,为什么我必须创建实例?弹簧不能为我做吗?
- .net - 实体框架 - 如何将复杂类型/表类型传递给函数
- kubernetes - Kubernetes + Helm - 仅在新版本/更改时重新启动 pod
- python - pandas to_sql giving UnicodeEncodeError for table with JSON column
- java - 我可以在一个 JSP 中有两个按钮吗?
- ansible - Ansible - 无法打印出空变量
- excel - Microsoft Excel -> 如何将颜色应用于交替行,但仅限于 X 和 Y 列(通过公式)
- sql - 如何在 SQLAlchemy > Presto 连接中指定 https 协议?