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
* watcher: correctly test if source is in the cwd
Make sure the path starts with ../ (after platform-specific slashes have been
corrected). Clarify existing test and add a case where the source starts with
two dots but is still in the current working directory.
* change handling of negated source patterns
Fixes#614. Allow negated source patterns to be specified without unsetting the
default negation patterns.
Allow source patterns to override the default negation patterns if they start
with one of the ignored directories.
* 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
Copy file name to clipboardExpand all lines: docs/recipes/watch-mode.md
+19-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,9 @@ 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. Note that if you specify a negative pattern the directories from [`ignore-by-default`] will no longer be ignored, so you may want to repeat these in your config.
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].
75
+
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.
65
77
66
78
If your tests write to disk they may trigger the watcher to rerun your tests. If this occurs you will need to use the `--source` flag.
67
79
@@ -81,17 +93,17 @@ You can quickly rerun all tests by typing <kbd>r</kbd> on the console, followed
81
93
82
94
## Debugging
83
95
84
-
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:
85
97
86
98
```console
87
-
$ DEBUG=ava:watcher npm test -- --watch
99
+
$ DEBUG=ava:watcher npm test -- --watch --verbose
88
100
```
89
101
90
102
On Windows use:
91
103
92
104
```console
93
105
$ set DEBUG=ava:watcher
94
-
$ npm test -- --watch
106
+
$ npm test -- --watch --verbose
95
107
```
96
108
97
109
## Help us make watch mode better
@@ -103,3 +115,4 @@ Watch mode is relatively new and there might be some rough edges. Please [report
0 commit comments