React + Jest单元测试中的Material-UI排版错误

问题描述 投票:0回答:1

当我在浏览器中运行应用程序时,我没有看到来自我的React Web应用程序的任何警告,但在我的单元测试运行期间,我收到Material-UI排版错误。

警告:Material-UI:您正在使用将在下一个主要版本中删除的已弃用的排版变体。请阅读https://material-ui.com/style/typography#migration-to-typography-v2下的迁移指南

请建议如何解决此问题。

迁移指南在这方面没有帮助,因为我已将所有Typography变体升级到文档中提到的最新版本。

@ material-ui / core版本:3.5.1

纱线运行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
reactjs unit-testing jestjs material-ui typography
1个回答
0
投票

看起来您没有使用与迁移指南中提到的主题类似的主题:

const theme = createMuiTheme({
  typography: {
    useNextVariants: true,
  },
});

如果您不使用主题,请设置window.__MUI_USE_NEXT_TYPOGRAPHY_VARIANTS__ = true;

© www.soinside.com 2019 - 2024. All rights reserved.