-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Components styled with emotion do not get theme from material theme provider #5664
Comments
As indicated by the warning:
this is a dual package issue of It looks like NodeJS is loading test: {
alias: {
'@emotion/react': path.resolve(
'node_modules/@emotion/react/dist/emotion-react.cjs.mjs'
),
},
}, Looking at https://publint.dev/@emotion/[email protected], the package exports is quite complicated, but seems legitimate, so it might be possible that Vite / Vitest's default resolution is doing something wrong. |
Well as workaround this works but I think it is not good that vite and vitest behave in a different way. |
I tried to decipher what's happening but unfortunately I couldn't figure out yet where this goes wrong. https://github.com/hi-ogawa/reproductions/tree/main/vitest-5664-mui-emotion-provider It seems like Vite SSR is fine, so Vitest / Vite-node might be making bad resolution. It could be a bug, so we can leave this issue open. |
Describe the bug
Having a react app using material ui and emotion/styled, components styled with emotion/styled do not receive the theme from the material ui ThemeProvider in tests.
This is working for production code.
As a workaround one could wrap the tested component into an additional theme provider from emotions. See also this stack overflow discussion.
Reproduction
A minimal example can be found in this StackBlitz sandbox
System Info
Used Package Manager
npm
Validations
The text was updated successfully, but these errors were encountered: