【发布时间】:2016-07-24 01:14:19
【问题描述】:
我使用 grunt 运行我的 mocha 测试,我在控制台中看到了测试结果,这没问题,问题是这个任务正在生成报告,但是当你运行这个 HTML 报告时,你只会看到运行在文本中的日志。 ..我想查看测试聚合,并且 mocha 单元测试运行正常,我在这里缺少什么?
mochaTest: {
test: {
options: {
reporter: 'spec',
colors: true,
summery: true,
captureFile: 'results.html', // Optionally capture the reporter output to a file
quiet: false, // Optionally suppress output to standard out (defaults to false)
clearRequireCache: true // Optionally clear the require cache before running tests (defaults to false)
},
src: ['test/*spec.js'],
excludes: ['plugins']
},
'travis-cov': {
options: {
reporter: 'travis-cov'
}
}
},
我使用包 grunt.loadNpmTasks('grunt-mocha-test');
https://github.com/pghalliday/grunt-mocha-test
我想要这样的报告或我可以使用的任何其他漂亮的 html 报告...
【问题讨论】:
-
您可以使用mochawesome。把你的记者换成
mochawesome! -
@IsmailRBOUH - 看起来不错,但您能举例说明如何在 GRUNT 中使用它吗?
-
只需
npm install --save-dev mochawesome然后将reporter: 'spec',更改为reporter: 'mochawesome',,grunt-mocha-test将完成剩下的工作! -
@IsmailRBOUH - 谢谢,我安装了软件包并使用 mochaTest 运行 grunt:{ test: { options: { 记者:'mochawesome',没有任何改变,我还想念别的吗?
-
@IsmailRBOUH - 对不起我的错 :) 请添加它作为答案,我会关闭它,非常感谢!
标签: javascript node.js gruntjs mocha.js