Skip to content

Commit

Permalink
fix watch mode
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronabramov committed Jul 20, 2017
1 parent 2b2b9ba commit 6212584
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ describe('Watch mode flows', () => {

// globalConfig is updated with the current pattern
expect(runJestMock.mock.calls[0][0].globalConfig).toEqual({
onlyChanged: true,
onlyChanged: false,
testNamePattern: '',
testPathPattern: 'p.*3',
watch: true,
Expand Down
7 changes: 7 additions & 0 deletions packages/jest-cli/src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ const runCLI = async (
(r: AggregatedResult) => (results = r),
);

if (argv.watch || argv.watchAll) {
// If in watch mode, return the promise that will never resolve.
// If the watch mode is interrupted, watch should handle the process
// shuttdown.
return new Promise(() => {});
}

if (!results) {
throw new Error(
'AggregatedResult must be present after test run is complete',
Expand Down
5 changes: 4 additions & 1 deletion packages/jest-cli/src/lib/update_global_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ module.exports = (
}

newConfig.onlyChanged = false;
newConfig.onlyChanged = !newConfig.watchAll && !newConfig.testNamePattern;
newConfig.onlyChanged =
!newConfig.watchAll &&
!newConfig.testNamePattern &&
!newConfig.testPathPattern;

if (options.noSCM) {
newConfig.noSCM = true;
Expand Down

0 comments on commit 6212584

Please sign in to comment.