jest icon indicating copy to clipboard operation
jest copied to clipboard

feat(jest-config): correctly resolve Jest test deps in monorepo that uses`pnpm`

Open hainenber opened this issue 1 month ago • 4 comments

Summary

Fixes #15876

For pnpm projects, it's better to use native JS runtime (bun, node or deno) to perform module resolution for default Jest test deps like @jest/test-sequencer and jest-environment-node. We shouldn't rely on third-party mechanisms like Rust-based resolvers when it comes to custom test deps.

IMO, this should be enabled for all package managers, not just pnpm but to prevent potential incidents, let's limit the blast radius to one packman only.

Test plan

  • [x] Test added.
  • [ ] Confirmation from affected user.

hainenber avatar Oct 26 '25 10:10 hainenber

Deploy Preview for jestjs ready!

Built without sensitive environment variables

Name Link
Latest commit bbb3f03808ede7a43a294526da232c6c57e551e9
Latest deploy log https://app.netlify.com/projects/jestjs/deploys/690226395832fd0008a3a796
Deploy Preview https://deploy-preview-15877--jestjs.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

netlify[bot] avatar Oct 26 '25 10:10 netlify[bot]

Open in StackBlitz

babel-jest

npm i https://pkg.pr.new/babel-jest@15877
babel-plugin-jest-hoist

npm i https://pkg.pr.new/babel-plugin-jest-hoist@15877
babel-preset-jest

npm i https://pkg.pr.new/babel-preset-jest@15877
create-jest

npm i https://pkg.pr.new/create-jest@15877
@jest/diff-sequences

npm i https://pkg.pr.new/@jest/diff-sequences@15877
expect

npm i https://pkg.pr.new/expect@15877
@jest/expect-utils

npm i https://pkg.pr.new/@jest/expect-utils@15877
jest

npm i https://pkg.pr.new/jest@15877
jest-changed-files

npm i https://pkg.pr.new/jest-changed-files@15877
jest-circus

npm i https://pkg.pr.new/jest-circus@15877
jest-cli

npm i https://pkg.pr.new/jest-cli@15877
jest-config

npm i https://pkg.pr.new/jest-config@15877
@jest/console

npm i https://pkg.pr.new/@jest/console@15877
@jest/core

npm i https://pkg.pr.new/@jest/core@15877
@jest/create-cache-key-function

npm i https://pkg.pr.new/@jest/create-cache-key-function@15877
jest-diff

npm i https://pkg.pr.new/jest-diff@15877
jest-docblock

npm i https://pkg.pr.new/jest-docblock@15877
jest-each

npm i https://pkg.pr.new/jest-each@15877
@jest/environment

npm i https://pkg.pr.new/@jest/environment@15877
jest-environment-jsdom

npm i https://pkg.pr.new/jest-environment-jsdom@15877
@jest/environment-jsdom-abstract

npm i https://pkg.pr.new/@jest/environment-jsdom-abstract@15877
jest-environment-node

npm i https://pkg.pr.new/jest-environment-node@15877
@jest/expect

npm i https://pkg.pr.new/@jest/expect@15877
@jest/fake-timers

npm i https://pkg.pr.new/@jest/fake-timers@15877
@jest/get-type

npm i https://pkg.pr.new/@jest/get-type@15877
@jest/globals

npm i https://pkg.pr.new/@jest/globals@15877
jest-haste-map

npm i https://pkg.pr.new/jest-haste-map@15877
jest-jasmine2

npm i https://pkg.pr.new/jest-jasmine2@15877
jest-leak-detector

npm i https://pkg.pr.new/jest-leak-detector@15877
jest-matcher-utils

npm i https://pkg.pr.new/jest-matcher-utils@15877
jest-message-util

npm i https://pkg.pr.new/jest-message-util@15877
jest-mock

npm i https://pkg.pr.new/jest-mock@15877
@jest/pattern

npm i https://pkg.pr.new/@jest/pattern@15877
jest-phabricator

npm i https://pkg.pr.new/jest-phabricator@15877
jest-regex-util

npm i https://pkg.pr.new/jest-regex-util@15877
@jest/reporters

npm i https://pkg.pr.new/@jest/reporters@15877
jest-resolve

npm i https://pkg.pr.new/jest-resolve@15877
jest-resolve-dependencies

npm i https://pkg.pr.new/jest-resolve-dependencies@15877
jest-runner

npm i https://pkg.pr.new/jest-runner@15877
jest-runtime

npm i https://pkg.pr.new/jest-runtime@15877
@jest/schemas

npm i https://pkg.pr.new/@jest/schemas@15877
jest-snapshot

npm i https://pkg.pr.new/jest-snapshot@15877
@jest/snapshot-utils

npm i https://pkg.pr.new/@jest/snapshot-utils@15877
@jest/source-map

npm i https://pkg.pr.new/@jest/source-map@15877
@jest/test-result

npm i https://pkg.pr.new/@jest/test-result@15877
@jest/test-sequencer

npm i https://pkg.pr.new/@jest/test-sequencer@15877
@jest/transform

npm i https://pkg.pr.new/@jest/transform@15877
@jest/types

npm i https://pkg.pr.new/@jest/types@15877
jest-util

npm i https://pkg.pr.new/jest-util@15877
jest-validate

npm i https://pkg.pr.new/jest-validate@15877
jest-watcher

npm i https://pkg.pr.new/jest-watcher@15877
jest-worker

npm i https://pkg.pr.new/jest-worker@15877
pretty-format

npm i https://pkg.pr.new/pretty-format@15877

commit: bbb3f03

pkg-pr-new[bot] avatar Oct 26 '25 10:10 pkg-pr-new[bot]

We should rely on third-party mechanisms like Rust-based resolvers when it comes to custom test deps.

I don't agree with this as any difference in resolution is a bug. If a dep is not resolved correctly in the config, there might be other discrepancies when running tests as well. So I'd rather fix the resolution bug within Jest

SimenB avatar Oct 27 '25 19:10 SimenB

I don't agree with this as any difference in resolution is a bug. If a dep is not resolved correctly in the config, there might be other discrepancies when running tests as well. So I'd rather fix the resolution bug within Jest

My bad for the typo, I mean we shouldn't rely on external module resolvers instead of native capability from JS runtimes.

hainenber avatar Oct 29 '25 14:10 hainenber