Skip to content

Commit

Permalink
Support for graceful extension of Jest config
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmfriedman committed May 2, 2019
1 parent 1a61db5 commit 633b45e
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/react-scripts/scripts/utils/createJestConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,25 @@ module.exports = (resolve, rootDir, isEjecting) => {
'extraGlobals',
'globalSetup',
'globalTeardown',
'moduleNameMapper',
'resetMocks',
'resetModules',
'snapshotSerializers',
'transform',
'transformIgnorePatterns',
'watchPathIgnorePatterns',
];
if (overrides) {
supportedKeys.forEach(key => {
if (overrides.hasOwnProperty(key)) {
config[key] = overrides[key];
if (Array.isArray(config[key]) || typeof config[key] !== 'object') {
// for arrays or primitive types, directly override the config key
config[key] = overrides[key];
} else {
// for object types, extend gracefully
config[key] = Object.assign({}, config[key], overrides[key]);
}

delete overrides[key];
}
});
Expand Down

0 comments on commit 633b45e

Please sign in to comment.