Skip to content
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

fix: pass resolve conditions when loading stub module #15489

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

andrew-the-drawer
Copy link

@andrew-the-drawer andrew-the-drawer commented Feb 4, 2025

Summary

Problem:

When stubbing the existing node_module package by another node_module package via moduleNameMapper settings, the resolve conditions are not respected. For example, in this PR, it does not resolve to browser export of the example-test-module when the test environment is jsdom.

Solution:

Pass through the options.conditions field in the resolveStubModuleName.

Test plan

Demonstrated in the unit test

Copy link

linux-foundation-easycla bot commented Feb 4, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

Copy link

netlify bot commented Feb 4, 2025

Deploy Preview for jestjs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 1accf78
🔍 Latest deploy log https://app.netlify.com/sites/jestjs/deploys/67aac4caccd1060008a95e17
😎 Deploy Preview https://deploy-preview-15489--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 site configuration.

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, this seems like a good change 👍

In addition to the inline comments, mind adding a changelog entry?

examples/react/package.json Outdated Show resolved Hide resolved
packages/jest-resolve/src/resolver.ts Outdated Show resolved Hide resolved
@andrew-the-drawer andrew-the-drawer force-pushed the fix/load-stub-module-conditions branch from c29e3b7 to 1accf78 Compare February 11, 2025 03:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants