Skip to content

Commit

Permalink
Let "--all" override "--onlyChanged" (#5486)
Browse files Browse the repository at this point in the history
* Let "--all" override "--onlyChanged"

* Add test
  • Loading branch information
mjesun authored and cpojer committed Feb 7, 2018
1 parent c9634d0 commit 87cd2ff
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
9 changes: 9 additions & 0 deletions packages/jest-config/src/__tests__/normalize.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
20 changes: 10 additions & 10 deletions packages/jest-config/src/normalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 87cd2ff

Please sign in to comment.