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
Implement file globbing and test matching within watch mode
Make watch mode interactive by allowing users to specify an additional glob pattern to select specific files, and a `--match` pattern to select specific tests. This means you no longer have to exit watch mode to achieve the same.
Co-authored-by: Michael Mulet <[email protected]>
Co-authored-by: Mark Wubben <[email protected]>
Copy file name to clipboardExpand all lines: docs/recipes/watch-mode.md
+28-1Lines changed: 28 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,6 +34,34 @@ export default {
34
34
35
35
If your tests write to disk they may trigger the watcher to rerun your tests. Configuring additional ignore patterns helps avoid this.
36
36
37
+
### Filter tests while watching
38
+
39
+
You may also filter tests while watching by using the CLI. For example, after running
40
+
41
+
```console
42
+
npx ava --watch
43
+
```
44
+
45
+
You will see a prompt like this:
46
+
47
+
```console
48
+
Type `g` followed by enter to filter test files by a glob pattern
49
+
Type `m` followed by enter to filter tests by their title
50
+
Type `r` followed by enter to rerun tests
51
+
Type `u` followed by enter to update snapshots in selected tests
52
+
>
53
+
```
54
+
55
+
So, to run only tests numbered like
56
+
57
+
- foo23434
58
+
- foo4343
59
+
- foo93823
60
+
61
+
You can type `m` and press enter, then type `foo*` and press enter. This will then run all tests that match that glob.
62
+
63
+
Afterwards you can use the `r` command to run the matched tests again, or `a` command to run **all** tests.
64
+
37
65
## Dependency tracking
38
66
39
67
AVA tracks which source files your test files depend on. If you change such a dependency only the test file that depends on it will be rerun. AVA will rerun all tests if it cannot determine which test file depends on the changed source file.
@@ -62,7 +90,6 @@ Sometimes watch mode does something surprising like rerunning all tests when you
this.lineWriter.writeLine(colors.error(`${figures.cross} Based on your configuration, ${count} test ${plur('file was','files were',count)} found, but did not match the CLI arguments:`+firstLinePostfix));
635
+
this.lineWriter.writeLine(colors.error(`${figures.cross} Based on your configuration, ${count} test ${plur('file was','files were',count)} found, but did not match the filters:`+firstLinePostfix));
0 commit comments