Skip to content

Commit aa6c91c

Browse files
authored
fix: Cannot start test script if config-overrides path is set via command line argument (#595)
1 parent 6372ca2 commit aa6c91c

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

overrides/jest.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,14 @@ packageJson.jest = jestOverrides;
2121
// override createJestConfig in memory
2222
require.cache[require.resolve(createJestConfigPath)].exports =
2323
() => overrides.jest(rewireJestConfig(config));
24-
// Passing the --scripts-version on to the original test script can result
24+
// Passing the --scripts-version and --config-overrides on to the original test script can result
2525
// in the test script rejecting it as an invalid option. So strip it out of
2626
// the command line arguments before invoking the test script.
2727
if (paths.customScriptsIndex > -1) {
2828
process.argv.splice(paths.customScriptsIndex, 2);
2929
}
30+
if (paths.configOverridesIndex > -1) {
31+
process.argv.splice(paths.configOverridesIndex, 2);
32+
}
3033

3134
module.exports = require(createJestConfigPath);

scripts/utils/paths.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ var config_overrides = customPath
1717
: `${ projectDir }/config-overrides`;
1818
const co_index = process.argv.indexOf('--config-overrides');
1919

20+
var has_co_argument = false;
2021
if (co_index > -1 && co_index + 1 <= process.argv.length) {
22+
has_co_argument = true;
2123
config_overrides = path.resolve(process.argv[co_index + 1]);
22-
process.argv.splice(co_index, 2);
2324
}
2425

2526
const scriptVersion = custom_scripts || 'react-scripts';
@@ -33,5 +34,6 @@ const paths = require(modulePath + '/config/paths');
3334
module.exports = Object.assign({
3435
scriptVersion: modulePath,
3536
configOverrides: config_overrides,
36-
customScriptsIndex: (custom_scripts ? cs_index : -1)
37+
customScriptsIndex: (custom_scripts ? cs_index : -1),
38+
configOverridesIndex: (has_co_argument ? co_index : -1),
3739
}, paths);

0 commit comments

Comments
 (0)