Skip to content

Commit 919e5cf

Browse files
committed
update watch mode docs
* Suggest `watch:test` as the npm script * Document how to always enable watch mode using the ava section in package.json * Recommend source patterns are configured through the ava section in package.json * Suggest using the verbose reporter when debugging
1 parent c4dfcbb commit 919e5cf

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

docs/recipes/watch-mode.md

+17-6
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,25 @@ You could also set up a special script:
3434
{
3535
"scripts": {
3636
"test": "ava",
37-
"test:watch": "ava --watch"
37+
"watch:test": "ava --watch"
3838
}
3939
}
4040
```
4141

4242
And then use:
4343

4444
```console
45-
$ npm run test:watch
45+
$ npm run watch:test
46+
```
47+
48+
Finally you could configure AVA to *always* run in watch mode by setting the `watch` key in the [`ava` section of your `package.json`]:
49+
50+
```json
51+
{
52+
"ava": {
53+
"watch": true
54+
}
55+
}
4656
```
4757

4858
Please note that the TAP reporter is unavailable when using watch mode.
@@ -61,7 +71,7 @@ In AVA there's a distinction between *source files* and *test files*. As you can
6171

6272
By default AVA watches for changes to the test files, `package.json`, and any other `.js` files. It'll ignore files in [certain directories](https://github.com/novemberborn/ignore-by-default/blob/master/index.js) as provided by the [`ignore-by-default`] package.
6373

64-
You can configure patterns for the source files using the [`--source` CLI flag] or in the `ava` section of your `package.json` file.
74+
You can configure patterns for the source files in the [`ava` section of your `package.json`] file, using the `source` key. This is the recommended way, though you could also use the [`--source` CLI flag].
6575

6676
You can specify patterns to match files in the folders that would otherwise be ignored, e.g. use `node_modules/some-dependency/*.js` to specify all `.js` files in `node_modules/some-dependency` as a source, even though normally all files in `node_modules` are ignored. Note that you need to specify an exact directory; `{bower_components,node_modules}/**/*.js` won't work.
6777

@@ -83,17 +93,17 @@ You can quickly rerun all tests by typing <kbd>r</kbd> on the console, followed
8393

8494
## Debugging
8595

86-
Sometimes watch mode does something surprising like rerunning all tests when you thought only a single test would be run. To see its reasoning you can enable a debug mode:
96+
Sometimes watch mode does something surprising like rerunning all tests when you thought only a single test would be run. To see its reasoning you can enable a debug mode. This will work best with the verbose reporter:
8797

8898
```console
89-
$ DEBUG=ava:watcher npm test -- --watch
99+
$ DEBUG=ava:watcher npm test -- --watch --verbose
90100
```
91101

92102
On Windows use:
93103

94104
```console
95105
$ set DEBUG=ava:watcher
96-
$ npm test -- --watch
106+
$ npm test -- --watch --verbose
97107
```
98108

99109
## Help us make watch mode better
@@ -105,3 +115,4 @@ Watch mode is relatively new and there might be some rough edges. Please [report
105115
[`--require` CLI flag]: https://github.com/sindresorhus/ava#cli
106116
[`--source` CLI flag]: https://github.com/sindresorhus/ava#cli
107117
[`.only` modifier]: https://github.com/sindresorhus/ava#running-specific-tests
118+
[`ava` section of your `package.json`]: https://github.com/sindresorhus/ava#configuration

0 commit comments

Comments
 (0)