Comments (3)
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.
from vitest.
As indicated by the warning:
stderr | node_modules/@ emotion/react/dist/emotion-react.esm.js:472:15
You are loading @emotion/react when it is already loaded. Running multiple instances may cause problems. This can happen if multiple versions are used, or if multiple builds of the same version are used.
this is a dual package issue of @emotion/react
. The one imported through @mui/material
(via NodeJS) and the other from your source code (via Vite/Vitest) are seeing different context singleton.
It looks like NodeJS is loading @emotion/react/dist/emotion-react.cjs.mjs
, so you can force Vitest's resolution via alias
:
https://stackblitz.com/edit/vitest-dev-vitest-wpfmsa?file=vitest.config.ts
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.
from vitest.
Well as workaround this works but I think it is not good that vite and vitest behave in a different way.
Isn't there a way to force the loading of the correct module on vitest side?
from vitest.
Related Issues (20)
- Windows drive casing causes issues with mocking
- Support for the experimental syntax 'decorators' isn't currently enabled
- Failed to update coverage thresholds. Configuration file is too complex. HOT 3
- Expose CDP in the browser mode
- Vitest hangs infinitely importing file with exported class Timeline. HOT 3
- Vitest cannot transpile with TypeScript `moduleResolution` set to `node16` HOT 2
- Browser: refreshing the page brakes `vitest` BroadcastChannel
- Mocking cyclic dependencies with `importOriginal` doesn't work in the browser
- docs: oder instead of order
- Vitest does not work when running from any CLI (Cannot find module @rollup) HOT 2
- vitest runner defaultSuite always empty HOT 1
- Ability to import source scripts in IFrames HOT 2
- Not possible to use stringContaining with toHaveBeenCalledWith HOT 1
- vitest 1.6.0 and axios tests fails with error `DataCloneError: function transformRequest` HOT 8
- String exports aren't resolved on wildcard imports HOT 1
- Vitest should install correct ui/browser package versions via CLI HOT 1
- coverage-istanbul does not work with workspaces and SvelteKit HOT 4
- Is it possible to add snapshots in type testing? HOT 2
- Async context is not passed into tests from fixtures HOT 2
- docs: clarify need to await `expect.toMatchFileSnapshot` HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vitest.