pnpm: Not working with Jest
pnpm version:
1.30.2
Code to reproduce the issue:
Step 1: Use pnpm
- Clone this repo
- Run
pnpm install - Run
pnpx jest
Step 2: Use yarn
- Delete
node_modules - Run
yarn - Run
yarn jest
Expected behavior:
Step 1 doesn’t fail
Actual behavior:
Step 1 fails while Step 2 doesn’t
TypeError: environment.setup is not a function
My speculation:
Flat node_modules doesn’t fail.
Additional question:
How to force pnpm create flat node_modules?
Additional information:
node -vprints: v9.4.0- Windows, OS X, or Linux?: Arch Linux
Related issue: https://github.com/facebook/jest/issues/5369
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 3
- Comments: 17 (7 by maintainers)
Same here, jest v29.7.0
Same here, jest v29.7.0
I stil get an error jest 29.3.1
It does work when doing
--shamefully-flatten, which is good news I suppose, but of course Jest should be fixed to work with hierarchical modules.Jest works now, v23.6.0
When working on our project, we noticed that jest had a couple problems correctly resolving symlinked paths. First, we had to upgrade Jest to ~21.2.1, where they weren’t missing dependencies in their package.json. Then, I noticed an issue with jest-resolve not properly resolving symlinks, so I created a PR for them, but don’t yet have a CLA to fix the issue. We ended up doing a patch in our tools instead. You might be experiencing similar issues. First, I would definitely advice upgrading Jest, if possible.
https://github.com/facebook/jest/pull/5085 https://github.com/Microsoft/web-build-tools/pull/466
Jest doesn’t work for me either, but the error is
SyntaxError: Unexpected token importon the line that imports my module (import { MyModule } from '..'). If I runnpm install; npm run testinstead ofpnpm install; pnpm run test, Jest works. I’m using the latest Jest, 22.3.0.@KSXGitHub’s workaround didn’t work (same error). My
.babelrcis{ "plugins": ["transform-es2015-modules-commonjs"] }because Jest doesn’t support native ES6 modules.