How to pass Themes emotion.d.ts typings to Unit Tests with Emotion v11 + Typescript

Viewed 242

I'm migrating my typescript react project with Emotion from v10 to v11. I've followed the documentation on https://emotion.sh/docs/typescript#define-a-theme to define a 3rd lib theme. It works building and running the app. But does not work with my jest tests anymore. It says theme is empty.

This is how I'm wrapping my components.

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",```
0 Answers
Related