Closed
Description
🚀 Feature Proposal
Merge the globals
property from any preset into the project configuration rather than overwriting it.
Motivation
Some third party libraries (e.g. ts-jest
) use the globals
property to provide configuration. It would be useful to be able to provide shared configuration and only override certain fields within the globals.
Example
The preset could look something like this :
module.exports = {
globals: {
'ts-jest': {
stringifyContentPathRegex: '\\.html$',
astTransformers: [
require.resolve('jest-preset-angular/InlineHtmlStripStylesTransformer')
],
isolatedModules: true
}
}
}
And the project config could simply contain the following :
module.exports = {
globals: {
'ts-jest': {
tsConfig: './tsconfig.spec.json',
}
}
}
(Or similar)
This would result in an options object which contained :
globals: {
'ts-jest': {
tsConfig: './tsconfig.spec.json',
stringifyContentPathRegex: '\\.html$',
astTransformers: [
require.resolve('jest-preset-angular/InlineHtmlStripStylesTransformer')
],
isolatedModules: true
}
}
This isn't limited to the configuration of third party libraries, but this may be the most obvious use case. A simple repro repo that illustrates how globals
currently gets clobbered is available at https://github.com/jdpearce/jest-globals-test