You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* 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
Copy file name to clipboardExpand all lines: docs/recipes/watch-mode.md
+17-6
Original file line number
Diff line number
Diff line change
@@ -34,15 +34,25 @@ You could also set up a special script:
34
34
{
35
35
"scripts": {
36
36
"test": "ava",
37
-
"test:watch": "ava --watch"
37
+
"watch:test": "ava --watch"
38
38
}
39
39
}
40
40
```
41
41
42
42
And then use:
43
43
44
44
```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
+
}
46
56
```
47
57
48
58
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
61
71
62
72
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.
63
73
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].
65
75
66
76
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.
67
77
@@ -83,17 +93,17 @@ You can quickly rerun all tests by typing <kbd>r</kbd> on the console, followed
83
93
84
94
## Debugging
85
95
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:
87
97
88
98
```console
89
-
$ DEBUG=ava:watcher npm test -- --watch
99
+
$ DEBUG=ava:watcher npm test -- --watch --verbose
90
100
```
91
101
92
102
On Windows use:
93
103
94
104
```console
95
105
$ set DEBUG=ava:watcher
96
-
$ npm test -- --watch
106
+
$ npm test -- --watch --verbose
97
107
```
98
108
99
109
## Help us make watch mode better
@@ -105,3 +115,4 @@ Watch mode is relatively new and there might be some rough edges. Please [report
0 commit comments