Is there a .mocha file where I can specify defaults such as --no-colors?
Yes. You can create a file ./test/mocha.opts
and in the file you can specify --no-colors
.
See mocha.opts on Mocha Doc for more information.
Mocha recommends mocha --config=.mocharc.json
.
There are new formats too, like yaml. See some examples.
Old answer:
The default is ./test/mocha.opts
. You can pass a custom path with the --opts
parameter :
mocha --opts ./mocha.opts
Useful in case you don’t store your tests in test/
folder, but next to code files, for example.
Any name and extension seems to work, so you can even do mocha --opts .mocharc
if you want it to go well with .jshintrc
, .babelrc
and the like.