-
-
Notifications
You must be signed in to change notification settings - Fork 790
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
Challenges using nanoid under jest with jsdom environment? #439
Comments
I recommend avoiding Jest because it too hacky and everything with ESM made it unusable. You can try Another option is to use Jest option to change import path of |
is this documented by chance? |
No. It is a hacky and non-recommended way. The only non-hacky way is to migrate to ESM. |
Some even bigger hacks can be found here |
thank you for these examples! I will just close for now |
Hi there
I am trying to use nanoid with jest with the jsdom environment, but this seems to import the specialized index.browser.js bundle, which uses pure-ESM statements, and then that causes challenges with jest when it's not configured for pure-ESM.
setting up a pure-ESM environment is hard, so I was hoping there might be a alternative solution. I would like to avoid custom jest configurations, because I want to use nanoid in a library, and don't really want my downstream users who may use jest to have to custom configure their jest either.
here is a small repro
https://github.com/cmdcolin/browser-nanoid-jest-repro
this issue happens with either nanoid v3 or v4 ( can change version in the repro package.json to see)
I know these bundle/esm issues are kind of tedious, if it is too specialized a use case, can close
The text was updated successfully, but these errors were encountered: