我最近将我的 react 应用程序从 material-ui v3 迁移到 v4,并用“@material-ui/styles”替换了“@material-ui/core/styles”,为了测试,我们使用了 jest 和酶。迁移后测试失败。我该如何解决这个问题?错误如下:
警告:Material-UI:styles提供的参数无效。您在上下文中提供没有主题的功能。父元素之一需要使用 ThemeProvider。错误:未捕获 [TypeError: theme.spacing is not a function] Full DOM 渲染 › 遇到声明异常 TypeError: theme.spacing is not a function
17 | },
18 | selectEmpty: {
> 19 | marginTop: theme.spacing(2),
| ^
20 | },
Run Code Online (Sandbox Code Playgroud)