我需要使用Multi Reporters for Mocha,所以我选择:
https://github.com/stanleyhlng/mocha-multi-reporters
一切都很好,但我需要使用自定义记者 - mocha-junit-reporter。
我如何在mocha-multi-reporter mocha-junit-reporter中使用?
我尝试过这样的事情:
"junitReporterOptions": {
"id": "junit",
"reporter": "mocha-junit-reporter",
"output": "../../cms2/raportUnitTestsjunit.xml"
},
但我已经" 记者没有找到! junit的" 。它与mocha-multi-reporter兼容吗?
1 个答案:
答案 0 :(得分:0)
你可以安装“mocha-multi-reporters@1.1.1”来使用“mocha-junit-reporter”自定义记者。
//文件:config.json
{
“记者启动”:“mocha-junit-reporter”,
“mochaJunitReporterReporterOptions”:{
“mochaFile”:“junit-custom.xml”
}
}
$ ./node_modules/.bin/mocha --reporter mocha-multi-reporter --reporter-options configFile = config.json
1..4
ok 1 mocha-test 1样品测试1.1
ok 2 mocha-test 1样品测试1.2
ok 3 mocha-test 2样品测试2.1
ok 4 mocha-test 2样品测试2.2#SKIP -
#test 3
#传递3
#wault 0
$ cat xunit-custom.xml
<?xml version =“1.0”encoding =“UTF-8”?>
< testsuites name =“Mocha Tests”time =“0.001”tests =“4”failure =“0”skipped =“1”>
< testsuite name =“Root Suite”timestamp =“2016-10-30T02:27:54”tests =“0”failure =“0”time =“0”>
< /测试套件>
< testsuite name =“mocha-test#1”timestamp =“2016-10-30T02:27:54”tests =“2”failure =“0”time =“0.001”>
< testcase name =“mocha-test#1样本测试#1.1”time =“0.001”classname =“样本测试#1.1”>
< /测试用例>
< testcase name =“mocha-test#1样本测试#1.2”time =“0”classname =“样本测试#1.2”>
< /测试用例>
< /测试套件>
< testsuite name =“mocha-test#2”timestamp =“2016-10-30T02:27:54”tests =“2”failure =“0”time =“0”>
< testcase name =“mocha-test#2样本测试#2.1”time =“0”classname =“样本测试#2.1”>
< /测试用例>
< /测试套件>
< /测试包>
您可以找到一个演示项目@ https://github.com/stanleyhlng/mocha-multi-reporters-demo
希望这有帮助!