Skip to content

Commit

Permalink
watch mode always runs all exclusive tests
Browse files Browse the repository at this point in the history
Fixes #635.
  • Loading branch information
novemberborn authored and sindresorhus committed Apr 6, 2016
1 parent 08ce255 commit e57908a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions docs/recipes/watch-mode.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ AVA tracks which source files your test files depend on. If you change such a de

Dependency tracking works for required modules. Custom extensions and transpilers are supported, provided you loaded them using the [`--require` CLI flag] and not from inside your test file. Files accessed using the `fs` module are not tracked.

## Watch mode and the `.only` modifier

This comment has been minimized.

Copy link
@forresst

forresst Apr 7, 2016

Contributor

@novemberborn I think we should add the hooks for the link (https://github.com/sindresorhus/ava#running-specific-tests) to work, replace :

## Watch mode and the `.only` modifier

By:

## Watch mode and the [`.only` modifier]

The `.only` modifier disables watch mode's dependency tracking algorithm. When a change is made, all `.only` tests will be rerun, regardless of whether the test depends on the changed file.

## Manually rerunning all tests

You can quickly rerun all tests by typing <kbd>r</kbd> on the console, followed by <kbd>Enter</kbd>.
Expand Down Expand Up @@ -96,3 +100,4 @@ Watch mode is relatively new and there might be some rough edges. Please [report
[`ignore-by-default`]: https://github.com/novemberborn/ignore-by-default
[`--require` CLI flag]: https://github.com/sindresorhus/ava#cli
[`--source` CLI flag]: https://github.com/sindresorhus/ava#cli
[`.only` modifier]: https://github.com/sindresorhus/ava#running-specific-tests
7 changes: 7 additions & 0 deletions lib/watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ function Watcher(logger, api, files, sources) {
}, this);

runOnlyExclusive = exclusiveFiles.length !== this.filesWithExclusiveTests.length;

if (runOnlyExclusive) {
// The test files that previously contained exclusive tests are always
// run, together with the remaining specific files.
var remainingFiles = diff(specificFiles, exclusiveFiles);
specificFiles = this.filesWithExclusiveTests.concat(remainingFiles);
}
}

this.busy = api.run(specificFiles || files, {
Expand Down
4 changes: 2 additions & 2 deletions test/watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ group('chokidar is installed', function (beforeEach, test, group) {
change(t4);
return debounce(2).then(function () {
t.ok(api.run.calledTwice);
t.same(api.run.secondCall.args, [[t3, t4], {runOnlyExclusive: true}]);
t.same(api.run.secondCall.args, [[t1, t2, t3, t4], {runOnlyExclusive: true}]);
});
});

Expand All @@ -950,7 +950,7 @@ group('chokidar is installed', function (beforeEach, test, group) {
change(t4);
return debounce(2).then(function () {
t.ok(api.run.calledTwice);
t.same(api.run.secondCall.args, [[t1, t4], {runOnlyExclusive: true}]);
t.same(api.run.secondCall.args, [[t1, t2, t4], {runOnlyExclusive: true}]);
});
});

Expand Down

0 comments on commit e57908a

Please sign in to comment.