-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
compilers deprecation
If you're here, you probably hit the deprecation notice. Sorry about that!
This is a soft deprecation, which means you get nagged about it, but it won't break (yet).
To suppress this warning, execute mocha with the --no-deprecation flag (though you won't get notice of any other deprecations you may encounter either).
--compilers is redundant; we've yet to encounter a real-world situation in which the solution couldn't be expressed using --require.
For example, --compilers coffee:coffee-script/register can be expressed as --require coffee-script/register. Likewise, --compilers js:babel-register can be expressed as --require babel-register.
However, Mocha loads only .js files by default when running all files in a directory. Therefore, to use a different file extension (such as .coffee), you will need to supply a glob instead of simply a directory. If this was how you ran Mocha pre-v4:
$ mocha --compilers coffee:coffee-script/register --recursive ./testThen this is how you'd accomplish the same thing (** roughly means "recursive") in v4:
$ mocha --register coffee-script/register "test/**/*.js"When you wrap a glob in quotes, file discovery is handed to the glob package. It's recommended to wrap in double-quotes, because the result should be the same regardless of your shell or environment (Windows/Linux/macOS, etc.).
glob is powerful. For instance, if your test dir has tests written in both JS and CoffeeScript, you could do this:
$ mocha --register coffee-script/register "test/**/*.{js,coffee}"When using --watch, you will also need to specify the extension(s) to watch via --watch-extensions, e.g.:
$ mocha --register coffee-script/register --watch --watch-extensions js,coffee "test/**/*.{js,coffee}"Any questions or trouble? Ask for help in our Gitter chat room!