-
-
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
moduleNameMapper with preset and additional config - override order #3565
Comments
I am experiencing the exact same issue and found the exact same lines to be the problem. "moduleNameMapper": {
"(.*)": "<rootDir>/src/$1"
}, Yip, you aren't going to get past that with the current setup. Unfortunately switching those 2 lines won't fix it because the preset will always override your configuration if you specify the same regex. What we really need is for our configuration to be tested first but to still be able to override the preset. I believe the following code change to those lines will do the trick: options.moduleNameMapper = Object.assign(
{},
options.moduleNameMapper,
preset.moduleNameMapper,
options.moduleNameMapper); This will add the settings from options first, then the ones from the preset, but then override with options in case one was overwritten by a preset. I will submit a pull request for this fix shortly. |
Adjusted the oder so that the options mappings are checked first and then the preset mappings are checked. The preset mappings can be overridden by the options mappings.
Adjusted the oder so that the options mappings are checked first and then the preset mappings are checked. The preset mappings can be overridden by the options mappings.
Adjusted the order so that the options mappings are checked first and then the preset mappings are checked. The preset mappings can be overridden by the options mappings.
Adjusted the order so that the options mappings are checked first and then the preset mappings are checked. The preset mappings can be overridden by the options mappings.
* Fix options.moduleNameMapper override order with preset (#3565) Adjusted the order so that the options mappings are checked first and then the preset mappings are checked. The preset mappings can be overridden by the options mappings. * Fix prettier linting issues * Fix eslint issues * Workaround in test for eslint sort-keys rule
…jestjs#3689) * Fix options.moduleNameMapper override order with preset (jestjs#3565) Adjusted the order so that the options mappings are checked first and then the preset mappings are checked. The preset mappings can be overridden by the options mappings. * Fix prettier linting issues * Fix eslint issues * Workaround in test for eslint sort-keys rule
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Do you want to request a feature or report a bug?
bug (or intended behavior)
What is the current behavior?
When using a preset and an additional configuration (on top of the preset) the
moduleNameMapper
property is merged from both preset and the additional configuration.The preset
moduleNameMapper
is assigned before the user-definedmoduleNameMapper
.What is the expected behavior?
User-defined
moduleNameMapper
should execute before preset definedmoduleNameMapper
.The current behaviour traps preset
moduleNameMapper
values thus not allowing override.The logic that implements the above can be found here
Switching lines 80 with 81 should solve it.
Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.
Node 7.4
Jest 20.0.1
yarn 19
The text was updated successfully, but these errors were encountered: