You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to run a Vitest unit test suite on a repo that uses "@emotion/react": "^11.14.0" and "@emotion/styled": "^11.14.0"
Vitest is complaining and will not run the tests because of the following reason
SyntaxError: Cannot use import statement outside a module
❯ Object.<anonymous> node_modules/@mui/styled-engine/node/index.js:47:38
Module /Users/bnussman/Development/emotion-vitest/node_modules/@emotion/styled/dist/emotion-styled.development.esm.js:1 seems to be an ES Module but shipped in a CommonJS package. You might want to create an issue to the package "@emotion/styled" asking them to ship the file in .mjs extension or add "type": "module"in their package.json.
As a temporary workaround you can try to inline the package by updating your config:
// vitest.config.js
export default {
test: {
server: {
deps: {
inline: [
"@emotion/styled"
]
}
}
}
}
To reproduce:
Go to https://github.com/bnussman/emotion-vitest/tree/main
Clone the repo
cd into the repo
Install dependencies with bun install
Run bun run test
Observe the issue
Expected behavior:
emotion to play nicely with Vitest out of the box
Environment information:
react version: 18.2.0
@emotion/react version: 11.14.0
The text was updated successfully, but these errors were encountered:
My tests are running with emotion if I choose to not include @emotion/react and @emotion/styled in the deps -> web -> optimizer.
I do lose a few seconds of performance from what I can see. Ideally they would be included for some performance gains on CI but I'm affected by the same problem you shared.
Current behavior:
I'm trying to run a Vitest unit test suite on a repo that uses
"@emotion/react": "^11.14.0"
and"@emotion/styled": "^11.14.0"
Vitest is complaining and will not run the tests because of the following reason
To reproduce:
https://github.com/bnussman/emotion-vitest/tree/main
bun install
bun run test
Expected behavior:
Environment information:
react
version:18.2.0
@emotion/react
version:11.14.0
The text was updated successfully, but these errors were encountered: