-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Add option to define a custom resolver #2998
Conversation
bbca42f
to
f512150
Compare
f512150
to
b4b99c4
Compare
b4b99c4
to
d56a4b0
Compare
Any updates for this? We need this type of functionality with linked dependencies during development... |
I still don't know how Jest works internally that well. The resolver in this PR, does it take the original arguments and return a path to the new module, or does it return an actual module? (I'm having trouble telling since your mock returns a string, so it could be either). For my use case, I need to be able to resolve paths to actual modules (the object itself), not just a path since the module could be in a totally different format (eg: AMD or even something custom), so CommonJS would not be able to load it. |
This resolver is expected to return a path to where the module is located, it does not allow you to return the actual module. If we need to also make it possible to directly return the module we need to do a larger change somewhere else, not in Both of the dependencies that @cpojer mentions in #2837, |
@Phoenixmatrix Looked at it a little more now and it seems that It seems that this is already possible to replace with an existing configuration option, |
Codecov Report
@@ Coverage Diff @@
## master #2998 +/- ##
==========================================
- Coverage 67.86% 67.86% -0.01%
==========================================
Files 147 148 +1
Lines 5349 5352 +3
==========================================
+ Hits 3630 3632 +2
- Misses 1719 1720 +1
Continue to review full report at Codecov.
|
This PR is somewhat related to #2925 since it affects the use of |
* Add option to define a custom resolver * Add documentation for resolver config option * Add test for when overriding default resolver * Made it more clear in the docs what resolver is expected to return
* Add option to define a custom resolver * Add documentation for resolver config option * Add test for when overriding default resolver * Made it more clear in the docs what resolver is expected to return
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. |
Summary
This PR addresses #2837, implementing a new configuration option called
resolver
that can be used to implement a custom resolver.This is a non breaking change.
Feedback about the approach is greatly appreciated and if this is a good way to solve #2837 in a general way. This works great for my use case.
Test plan
All existing tests pass along with the new one added for testing the new functionality.