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 requireActual fail with moduleNameMapper #8210

Merged
merged 5 commits into from Mar 27, 2019

Conversation

levinqdl
Copy link
Contributor

Summary

This PR fixes #7981 , requireActual not work with moduleNameMapper, witch currently throws an error.

This PR make jest-resolve resolveModule invoke resolveStubModuleName, which resolves module with moduleNameMapper. resolveStubModuleName is invoked before resolveModuleFromDirIfExists, so that moduleNameMapper config can override default behavior.

Test plan

Test requireActual with a moduleNameMapper configuration, and it should resolve the module successfully.

@codecov-io
Copy link

codecov-io commented Mar 25, 2019

Codecov Report

Merging #8210 into master will increase coverage by 0.04%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8210      +/-   ##
==========================================
+ Coverage   62.29%   62.34%   +0.04%     
==========================================
  Files         265      265              
  Lines       10551    10551              
  Branches     2563     2564       +1     
==========================================
+ Hits         6573     6578       +5     
+ Misses       3388     3385       -3     
+ Partials      590      588       -2
Impacted Files Coverage Δ
packages/jest-resolve/src/index.ts 44.11% <100%> (+3.67%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4b3483e...8bcdffb. Read the comment docs.

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 for the PR! I think this makes sense :)

CHANGELOG.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@thymikee thymikee left a comment

Choose a reason for hiding this comment

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

Looks good! It also doesn't seem to cause measurable performance impact (cold & warm cache) for a non-mapped test suite as we have in src/packages/*.

Would like @scotthovestadt to also have a look

@levinqdl mind resolving the conflicts?

@levinqdl levinqdl force-pushed the requireActual-with-moduleNameMapper branch from 1c63982 to 883773e Compare March 27, 2019 02:20
@levinqdl
Copy link
Contributor Author

levinqdl commented Mar 27, 2019

Hi @thymikee, conflicts have been resolved.

@thymikee thymikee merged commit 0f43bdd into jestjs:master Mar 27, 2019
@thymikee
Copy link
Collaborator

Ok, merging. Thanks you so much @levinqdl! Looking forward to future contributions :)

@frontendphil
Copy link

This just broke quite a lot of our tests, so I came here to complain but then realized that we relied on a buggy implementation and that I misread the docs. Fixed our setup and needed to leave this comment.

hedgepigdaniel added a commit to respond-framework/rudy that referenced this pull request Apr 7, 2019
hedgepigdaniel added a commit to respond-framework/rudy that referenced this pull request Apr 11, 2019
* Remove the need to import built versions of packages in integration tests using jest's moduleNameMapper option

* Upgrade jest with bugfix: jestjs/jest#8210

* prettify
@github-actions
Copy link

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 May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

require.requireActual no longer seems to use moduleNameMapper when resolving path
6 participants