Reputation: 33544
When I run npm test
it outputs:
mocha ./tests/ --recursive --reporter mocha-junit-reporter
And all tests run well. But when I try to invoke mocha ./tests/flickr/mytest --reporter junit-reporter
I got:
Unknown "reporter": junit-reporter
How to pass it correctly?
Upvotes: 5
Views: 12468
Reputation: 8443
I spotted two issues in your command:
mocha ./tests/flickr/mytest --reporter junit-reporter
First issue is mocha
in above is a mocha command from global node module. However, when executing npm test
, it actually targets local mocha
command inside our node_modules
folder.
Second issue is the name of reporter should be mocha-junit-reporter
not junit-reporter
Workaround is to target local mocha
./node_modules/.bin/mocha ./tests/flickr/mytest --reporter mocha-junit-reporter
This is preferrable solution.
Alternative solution is to install mocha-junit-reporter
for global node modules as below:
npm install -g mocha-junit-reporter
mocha ./tests/flickr/mytest --reporter mocha-junit-reporter
This is not too preferrable because you can target different version of mocha and mocha-junit-reporter in global compare to the one in local node modules.
Cheers
Upvotes: 2