Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix watch mode #4084

Merged
merged 1 commit into from
Jul 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be the correct value. If we have a pattern, we don't match only changed files, we match all files

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
// shutdown.
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