【发布时间】:2024-05-19 19:25:01
【问题描述】:
当我在浏览器中运行我的 React Web 应用程序时,我没有看到任何警告,但在我的单元测试运行期间,我收到了 Material-UI 排版错误。
警告:Material-UI:您正在使用已弃用的排版变体,这些变体将在下一个主要版本中删除。 请阅读https://material-ui.com/style/typography#migration-to-typography-v2下的迁移指南
请建议如何解决该问题。
迁移指南在这方面没有帮助,因为我已将所有 Typography 变体升级到文档中提到的最新版本。
@material-ui/core 版本:3.5.1
yarn run v1.9.4 $ node scripts/test.js --env=jsdom
PASS src/containers/Login/Login.spec.js ● 控制台
console.error node_modules/warning/warning.js:34 Warning: Material-UI: you are using the deprecated typography variants that will be removed in the next major release. Please read the migration guide under https://material-ui.com/style/typography#migration-to-typography-v2
【问题讨论】:
-
请包含您的@material-ui/core 版本和完整的错误消息(包括堆栈跟踪)
-
@epsilon 已更新。
-
看起来您忘记了堆栈跟踪。您是否真的在测试中将组件包装在 MuiThemeProvider 中?大多数人不这样做是因为他们依赖于浅层渲染。
标签: reactjs unit-testing jestjs material-ui typography