admin管理员组文章数量:1317906
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?
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?
Share Improve this question edited Mar 29, 2019 at 11:19 Nino Filiu 18.6k11 gold badges62 silver badges96 bronze badges asked Mar 29, 2019 at 10:54 CherryCherry 33.6k74 gold badges243 silver badges394 bronze badges2 Answers
Reset to default 4From mocha-junit-reporter
's readme:
# install the package
npm install mocha-junit-reporter --save-dev
# run the test with reporter
mocha test --reporter mocha-junit-reporter --reporter-options mochaFile=./path_to_your/file.xml
I spotted two issues in your mand:
mocha ./tests/flickr/mytest --reporter junit-reporter
First issue is mocha
in above is a mocha mand from global node module. However, when executing npm test
, it actually targets local mocha
mand inside our node_modules
folder.
Second issue is the name of reporter should be mocha-junit-reporter
not junit-reporter
Solution
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 pare to the one in local node modules.
Cheers
本文标签: javascriptHow to run mocha tests with reporterStack Overflow
版权声明:本文标题:javascript - How to run mocha tests with reporter? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742031457a2416518.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论