From 87cd2ffdd5bd7c8bf0b97dfd7adf22f29f1ca919 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Jim=C3=A9nez=20Es=C3=BAn?= Date: Wed, 7 Feb 2018 13:57:23 +0100 Subject: [PATCH] Let "--all" override "--onlyChanged" (#5486) * Let "--all" override "--onlyChanged" * Add test --- .../src/__tests__/normalize.test.js | 9 +++++++++ packages/jest-config/src/normalize.js | 20 +++++++++---------- 2 files changed, 19 insertions(+), 10 deletions(-) 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,