Skip to content

Commit 87cd2ff

Browse files
mjesuncpojer
authored andcommitted
Let "--all" override "--onlyChanged" (#5486)
* Let "--all" override "--onlyChanged" * Add test
1 parent c9634d0 commit 87cd2ff

2 files changed

Lines changed: 19 additions & 10 deletions

File tree

packages/jest-config/src/__tests__/normalize.test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,4 +1131,13 @@ describe('testPathPattern', () => {
11311131
});
11321132
expect(options.testPathPattern).toBe('a|b|c|d');
11331133
});
1134+
1135+
it('gives precedence to --all', () => {
1136+
const {options} = normalize(initialOptions, {
1137+
all: true,
1138+
onlyChanged: true,
1139+
});
1140+
1141+
expect(options.onlyChanged).toBe(false);
1142+
});
11341143
});

packages/jest-config/src/normalize.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,16 @@ export default function normalize(options: InitialOptions, argv: Argv) {
526526

527527
newOptions.testFailureExitCode = parseInt(newOptions.testFailureExitCode, 10);
528528

529+
for (const key of [
530+
'lastCommit',
531+
'changedFilesWithAncestor',
532+
'changedSince',
533+
]) {
534+
if (newOptions[key]) {
535+
newOptions.onlyChanged = true;
536+
}
537+
}
538+
529539
if (argv.all) {
530540
newOptions.onlyChanged = false;
531541
} else if (newOptions.testPathPattern) {
@@ -572,16 +582,6 @@ export default function normalize(options: InitialOptions, argv: Argv) {
572582
);
573583
}
574584

575-
for (const key of [
576-
'lastCommit',
577-
'changedFilesWithAncestor',
578-
'changedSince',
579-
]) {
580-
if (newOptions[key]) {
581-
newOptions.onlyChanged = true;
582-
}
583-
}
584-
585585
return {
586586
hasDeprecationWarnings,
587587
options: newOptions,

0 commit comments

Comments
 (0)