From d941a3e99cf2f2718c2f5a5608c3d87f1bad49d5 Mon Sep 17 00:00:00 2001 From: Miguel Jimenez Esun Date: Wed, 7 Feb 2018 11:47:05 +0000 Subject: [PATCH 1/2] Let "--all" override "--onlyChanged" --- packages/jest-config/src/normalize.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) 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, From e302a28426296d66b02bdd917f156c85ffa69eb5 Mon Sep 17 00:00:00 2001 From: Miguel Jimenez Esun Date: Wed, 7 Feb 2018 11:58:51 +0000 Subject: [PATCH 2/2] Add test --- packages/jest-config/src/__tests__/normalize.test.js | 9 +++++++++ 1 file changed, 9 insertions(+) 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); + }); });