-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
area: node.jscommand-line-or-Node.js-specificcommand-line-or-Node.js-specifictype: featureenhancement proposalenhancement proposal
Description
Is your feature request related to a problem or a nice-to-have?? Please describe.
When using the --watch option Mocha reruns tests when files change. This is quite helpful but the current implementation suffers from a couple of problems. I’d be more than glad to implement the required changes.
Current problems
- New files are not picked up (cli don't watch new added file #2176)
- What files to watch can only be controlled by the
extensionsconfiguration. In particular that makes the following uses impossible:- Only watch files in a certain directory (To specify watching directories with mocha-cli #2702)
- Watch files without extensions
- Exclude certain files and directories from watching (Allow to customize ignored files? #2554)
- It always uses the slow
fs.watchFileeven whenfs.watchis available. - It is impossible to watch files in
node_modulesand.git
Describe the solution you'd like
- Use
chokidarto get reliable and fast file watching. - Add a
watchFiles(name subject to bikeshedding) configuration option that accepts a list of file paths, directories, and globs to watch. - Rerun tests when a file matching
watchFilesis added - Add
watchIgnore(name subject to bikeshedding) that accept a list of globs to exclude from watching. Defaults to['node_modules', '.git/**'] - Keep backwards compatibility if none of the new options are specified
Describe alternatives you've considered
Using nodemon would address all the problems. Since this creates a new process on file changes this approach is to slow, especially when using Babel or TypeScript for on-the-fly compilation. There also has been talk (#1780) of deprecating the --watch options and use separate tools to accomplish reruns. However people are relying on watch (#1780 (comment)).
David-Else and oliviertassinari
Metadata
Metadata
Assignees
Labels
area: node.jscommand-line-or-Node.js-specificcommand-line-or-Node.js-specifictype: featureenhancement proposalenhancement proposal