Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: pass resolve conditions when loading stub module#15489

Merged
SimenB merged 9 commits into
jestjs:mainfrom
andrew-the-drawer:fix/load-stub-module-conditions
Feb 14, 2025
Merged

fix: pass resolve conditions when loading stub module#15489
SimenB merged 9 commits into
jestjs:mainfrom
andrew-the-drawer:fix/load-stub-module-conditions

Conversation

@andrew-the-drawer
Copy link
Copy Markdown
Contributor

@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

@linux-foundation-easycla
Copy link
Copy Markdown

linux-foundation-easycla Bot commented Feb 4, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

@netlify
Copy link
Copy Markdown

netlify Bot commented Feb 4, 2025

Deploy Preview for jestjs ready!

Name Link
🔨 Latest commit 1fa2298
🔍 Latest deploy log https://app.netlify.com/sites/jestjs/deploys/67af75c37fa81d0009cb9029
😎 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
Copy Markdown
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?

Comment thread examples/react/package.json Outdated
Comment thread packages/jest-resolve/src/resolver.ts Outdated
@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
Copy link
Copy Markdown
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!

@SimenB SimenB merged commit 4a4c031 into jestjs:main Feb 14, 2025
@github-actions
Copy link
Copy Markdown

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Mar 17, 2025
@andrew-the-drawer andrew-the-drawer deleted the fix/load-stub-module-conditions branch May 29, 2025 16:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants