If you are using Jest v26, you might need to patch it in order to load modules with proper server/client environments. Don't do this until you actually encounter issues.
- Install
patch-package
and follow its setup instructions - If using the last version of
jest
(26.6.3
), copy thispatches
folder to your project root and runnpx patch-package
oryarn patch-package
. - If using
jest < v26.6.3
update manuallynode_modules/jest-runtime/build/index.js
file replicating this commit and runnpx patch-package jest-runtime
oryarn patch-package jest-runtime
If using Yarn v2 you might try the approach described here.