diff --git a/packages/jest-config/src/__tests__/normalize.test.js b/packages/jest-config/src/__tests__/normalize.test.js index c92f3364f59e..b15b7eed0c4c 100644 --- a/packages/jest-config/src/__tests__/normalize.test.js +++ b/packages/jest-config/src/__tests__/normalize.test.js @@ -1131,4 +1131,13 @@ describe('testPathPattern', () => { }); expect(options.testPathPattern).toBe('a|b|c|d'); }); + + it('gives precedence to --all', () => { + const {options} = normalize(initialOptions, { + all: true, + onlyChanged: true, + }); + + expect(options.onlyChanged).toBe(false); + }); }); diff --git a/packages/jest-config/src/normalize.js b/packages/jest-config/src/normalize.js index b5c04c0a8acf..6cf845e3fff1 100644 --- a/packages/jest-config/src/normalize.js +++ b/packages/jest-config/src/normalize.js @@ -526,6 +526,16 @@ export default function normalize(options: InitialOptions, argv: Argv) { newOptions.testFailureExitCode = parseInt(newOptions.testFailureExitCode, 10); + for (const key of [ + 'lastCommit', + 'changedFilesWithAncestor', + 'changedSince', + ]) { + if (newOptions[key]) { + newOptions.onlyChanged = true; + } + } + if (argv.all) { newOptions.onlyChanged = false; } else if (newOptions.testPathPattern) { @@ -572,16 +582,6 @@ export default function normalize(options: InitialOptions, argv: Argv) { ); } - for (const key of [ - 'lastCommit', - 'changedFilesWithAncestor', - 'changedSince', - ]) { - if (newOptions[key]) { - newOptions.onlyChanged = true; - } - } - return { hasDeprecationWarnings, options: newOptions,