reactjs - 如何将 Themes emotion.d.ts 类型传递给使用 Emotion v11 + Typescript 的单元测试
我正在将我的使用 Emotion 的 TypeScript React 项目从 v10 迁移到 v11。我按照 https://emotion.sh/docs/typescript#define-a-theme 上的文档定义了第三方库主题。构建和运行应用程序时可以正常工作,但在我的 Jest 测试中不再有效。它显示 theme 是空的。
这就是我包装我的组件的方式。
export const TestComponent: React.FC<Props> = ({ children }) => (
<StylesProvider injectFirst>
<ThemeProvider theme={theme}>
<StyledThemeProvider theme={theme}>
{children}
</StyledThemeProvider>
</ThemeProvider>
</StylesProvider>
);
"@types/jest": "^26.0.20",
"typescript": "4.1.3",
"@emotion/react": "^11.1.4",
"@emotion/styled": "^11.0.0",
"@testing-library/dom": "7.29.4",
"@testing-library/jest-dom": "^5.11.9",
"@testing-library/react": "^11.2.3",```