diff --git a/packages/jest-cli/src/__tests__/watch_filename_pattern_mode.test.js b/packages/jest-cli/src/__tests__/watch_filename_pattern_mode.test.js index 3d56e40f97c3..561840dbba14 100644 --- a/packages/jest-cli/src/__tests__/watch_filename_pattern_mode.test.js +++ b/packages/jest-cli/src/__tests__/watch_filename_pattern_mode.test.js @@ -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, diff --git a/packages/jest-cli/src/cli/index.js b/packages/jest-cli/src/cli/index.js index 65ccc7dc6345..27a10c99c441 100644 --- a/packages/jest-cli/src/cli/index.js +++ b/packages/jest-cli/src/cli/index.js @@ -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 + // shutdown. + return new Promise(() => {}); + } + if (!results) { throw new Error( 'AggregatedResult must be present after test run is complete', diff --git a/packages/jest-cli/src/lib/update_global_config.js b/packages/jest-cli/src/lib/update_global_config.js index 85f52b5e75f2..9af007f0a738 100644 --- a/packages/jest-cli/src/lib/update_global_config.js +++ b/packages/jest-cli/src/lib/update_global_config.js @@ -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;