-
-
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
Make it possible to merge transform
option with preset
#5505
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,21 @@ const PRESET_NAME = 'jest-preset' + JSON_EXTENSION; | |
const createConfigError = message => | ||
new ValidationError(ERROR, message, DOCUMENTATION_NOTE); | ||
|
||
const mergeOptionWithPreset = ( | ||
options: InitialOptions, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I hope it is fine. This is the first time I update code that uses Flow :) |
||
preset: InitialOptions, | ||
optionName: string, | ||
) => { | ||
if (options[optionName] && preset[optionName]) { | ||
options[optionName] = Object.assign( | ||
{}, | ||
options[optionName], | ||
preset[optionName], | ||
options[optionName], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do we have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To preserve the order of keys in the config that is overriding preset. I had the same question initially 😃 Maybe an inline comment with explanation would help? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I think so. |
||
); | ||
} | ||
}; | ||
|
||
const setupPreset = ( | ||
options: InitialOptions, | ||
optionsPreset: string, | ||
|
@@ -81,14 +96,8 @@ const setupPreset = ( | |
options.modulePathIgnorePatterns, | ||
); | ||
} | ||
if (options.moduleNameMapper && preset.moduleNameMapper) { | ||
options.moduleNameMapper = Object.assign( | ||
{}, | ||
options.moduleNameMapper, | ||
preset.moduleNameMapper, | ||
options.moduleNameMapper, | ||
); | ||
} | ||
mergeOptionWithPreset(options, preset, 'moduleNameMapper'); | ||
mergeOptionWithPreset(options, preset, 'transform'); | ||
|
||
return Object.assign({}, preset, options); | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
babel-jest
isn't explicitly set, so it doesn't appendregenerator-runtime
anymore.