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

Add --watchAll option #1469

Closed
wants to merge 1 commit into from
Closed
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
20 changes: 15 additions & 5 deletions packages/jest-cli/src/cli/args.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ const check = (argv: Object) => {
);
}

if (argv.watchExtensions && argv.watch === undefined) {
if (argv.onlyChanged && argv.watchAll) {
throw new Error(
'--watchExtensions can only be specified together with --watch.',
'Both --onlyChanged and --watchAll were specified, but these two ' +
'options do not make sense together. Try the --watch option which ' +
'reruns only tests related to changed files.',
);
}

Expand Down Expand Up @@ -148,10 +150,18 @@ const options = {
watch: {
description: wrap(
'Watch files for changes and rerun tests related to changed files. ' +
'If you want to re-run all tests when a file has changed, you can ' +
'call Jest using `--watch=all`.',
'If you want to re-run all tests when a file has changed, use the ' +
'`--watchAll` option.',
),
type: 'string',
type: 'boolean',
},
watchAll: {
description: wrap(
'Watch files for changes and rerun all tests. If you want to re-run ' +
'only the tests related to the changed files, use the ' +
'`--watch` option.',
),
type: 'boolean',
},
bail: {
alias: 'b',
Expand Down
8 changes: 3 additions & 5 deletions packages/jest-cli/src/jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function buildTestPathPatternInfo(argv) {
return {
lastCommit: argv.lastCommit,
onlyChanged: true,
watch: argv.watch !== undefined,
watch: argv.watch,
};
}
if (argv.testPathPattern) {
Expand Down Expand Up @@ -151,10 +151,8 @@ function runCLI(argv: Object, root: Path, onComplete: () => void) {
pipe.write('test framework = ' + testFramework.name + '\n');
pipe.write('config = ' + JSON.stringify(config, null, ' ') + '\n');
}
if (argv.watch !== undefined) {
if (argv.watch !== 'all') {
argv.onlyChanged = true;
}
if (argv.watch || argv.watchAll) {
argv.onlyChanged = !argv.watchAll;

return new Promise(resolve => {
getWatcher(config, root, watcher => {
Expand Down