Reputation: 1481
Im trying to get Mocha reporter to output a html file, using the mocha.opts
configuration file:
--compilers coffee:coffee-script/register
--reporter html-cov > tests.html
However this always returns the following:
→ mocha
/usr/local/lib/node_modules/mocha/bin/_mocha:432
if (!files.length) throw new Error("cannot resolve path (or pattern) '"
^
Error: cannot resolve path (or pattern) '>'
If I pass the command mocha --reporter html-cov > testes.html
directly in the shell it does work.
What am I missing?
Upvotes: 1
Views: 2199
Reputation: 151491
You can't put the redirection in mocha.opts
. When you do it on the command line, the whole command is interpreted by the shell and >
is understood to be a redirection. However the mocha.opts
file is meant to be read as options and only options, nothing else. Mocha is not able to figure out that > tests.html
is meant to be a redirection. You can put this in your mocha.opts
:
--compilers coffee:coffee-script/register
--reporter html-cov
and keep > tests.html
on the command line or use a wrapper script if you want to avoid typing it.
If there were an option to tell Mocha to output into a specific file (for instance, --output file
) then you could put that in mocha.opts
but Mocha has no such option right now.
Upvotes: 3