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
This change improves the file watching behavior and fixes#3912.
* We introduce the `--watch-files` command line option. This option
allows control over which files are and is separate and more powerful
than `--extension`. Fixes#2702.
* We introduce the `--watch-ignore` command line option that allows
control over which files are not watched. Before this was hardcoded to
`node_modules` and `.git`. See #2554.
* The `chokidar` package now handles file watching. (We’re using version
`2.1.6` instead of `3.x` because the latter dropped support for Node
v6.)
* New test files are picked up by the file watcher and run. Fixes#2176.
Copy file name to clipboardExpand all lines: docs/index.md
+27-7Lines changed: 27 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1087,16 +1087,36 @@ Files specified using `--file` _are not affected_ by this option.
1087
1087
1088
1088
Can be specified multiple times.
1089
1089
1090
-
### `--extension <ext>, --watch-extensions <ext>`
1091
-
1092
-
> _Updated in v6.0.0. Previously `--watch-extensions`, but now expanded to affect general test file loading behavior. `--watch-extensions` is now an alias_
1090
+
### `--extension <ext>`
1093
1091
1094
1092
Files having this extension will be considered test files. Defaults to `js`.
1095
1093
1096
-
Affects `--watch` behavior.
1097
-
1098
1094
Specifying `--extension` will _remove_`.js` as a test file extension; use `--extension js` to re-add it. For example, to load `.mjs` and `.js` test files, you must supply `--extension mjs --extension js`.
1099
1095
1096
+
The option can be given multiple times. The option accepts a comma-delimited list: `--extension a,b` is equivalent to `--extension a --extension b`
1097
+
1098
+
### `--watch-files <file|directory|glob>`
1099
+
1100
+
> _New in v7.0.0_
1101
+
1102
+
List of paths or globs to watch when `--watch` is set. If a file matching the given glob changes or is added or removed mocha will rerun all tests.
1103
+
1104
+
If the path is a directory all files and subdirectories will be watched.
1105
+
1106
+
By default all files in the current directory having one of the extensions provided by `--extension` and not contained in the `node_modules` or `.git` folders are watched.
1107
+
1108
+
The option can be given multiple times. The option accepts a comma-delimited list: `--watch-files a,b` is equivalent to `--watch-files a --watch-files b`
1109
+
1110
+
### `--watch-ignore <file|directory|glob>`
1111
+
1112
+
> _New in v7.0.0_
1113
+
1114
+
List of paths or globs to exclude from watching. Defaults to `node_modules` and `.git`.
1115
+
1116
+
To exclude all files in a directory it is preferable to use `foo/bar` instead of `foo/bar/**/*`. The latter will still watch the directory `foo/bar` but will ignore all changes to the content of that directory.
1117
+
1118
+
The option can be given multiple times. The option accepts a comma-delimited list: `--watch-ignore a,b` is equivalent to `--watch-ignore a --watch-ignore b`
1119
+
1100
1120
### `--file <file|directory|glob>`
1101
1121
1102
1122
Explicitly _include_ a test file to be loaded before other test files files. Multiple uses of `--file` are allowed, and will be loaded in order given.
@@ -1132,9 +1152,9 @@ Sort test files (by absolute path) using [Array.prototype.sort][mdn-array-sort].
1132
1152
1133
1153
### `--watch, -w`
1134
1154
1135
-
Executes tests on changes to JavaScript in the current working directory (and once initially).
1155
+
Rerun tests on file changes.
1136
1156
1137
-
By default, only files with extension `.js` are watched. Use `--extension` to change this behavior.
1157
+
The `--watch-files` and `--watch-ignore` options can be used to control which files are watched for changes.
0 commit comments