Skip to content

Improve file watching #3912

@geigerzaehler

Description

@geigerzaehler

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

Describe the solution you'd like

  • Use chokidar to 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 watchFiles is 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)).

Metadata

Metadata

Assignees

Labels

area: node.jscommand-line-or-Node.js-specifictype: featureenhancement proposal

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions