【发布时间】:2014-03-16 21:58:18
【问题描述】:
我正在使用grunt-mocha-test 运行我们的 mocha 测试。我希望能够运行测试并生成 xunit 报告并获得覆盖率(使用毯子.js)。我的 gruntfile 中有以下部分:
mochaTest: {
'unit-jenkins': {
options: {
reporter: 'XUnit',
require: paths.test + '/blanket',
captureFile: paths.tmp + '/xunit.xml'
},
src: [paths.test + '/unit/**/*.js'],
},
'integration-jenkins': {
options: {
reporter: 'XUnit',
require: paths.test + '/blanket',
captureFile: paths.tmp + '/xunit.xml'
},
src: [paths.test + '/integration/**/*.js']
},
coverage: {
options: {
reporter: 'html-cov',
quiet: true,
captureFile: paths.tmp + '/coverage.html'
},
src: [paths.test + '/**/*.js']
}
},
和
grunt.registerTask('test-jenkins', [
'mochaTest:unit-jenkins', // run unit tests
'mochaTest:integration-jenkins', // run unit tests
]);
当我运行 grunt test-jenkins 时,我可以在控制台上看到测试输出和 xunit 输出。此外,创建了 xunit 文件,但是,它包含测试输出和 xunit 输出,例如:
[14:30:17.164Z] TRACE App: HTTP Response /versions
HTTP/1.1 200 OK
HTTP/1.1 200 OK
X-Powered-By: Express
Content-Type: application/json; charset=utf-8
Content-Length: 46
ETag: "-1409762768"
Date: Mon, 17 Feb 2014 14:30:17 GMT
Connection: close
<testsuite name="Mocha Tests" tests="1" failures="0" errors="0" skipped="0" timestamp="Mon, 17 Feb 2014 14:30:17 GMT" time="0.029">
<testcase classname="Application" name="should contain description of API versions" time="0.028"/>
</testsuite>
应该如何配置 grunt-mocha-test 以使 xunit 输出文件仅包含 xunit 输出?
【问题讨论】:
-
也许尝试使用github.com/flatiron/winston 并在检测到 process.env.NODE_ENV = test 时删除控制台传输?
标签: node.js gruntjs mocha.js xunit