【问题标题】:How can I get my grunt mocha test result in a html file?如何在 html 文件中获取我的 grunt mocha 测试结果?
【发布时间】:2018-05-17 15:24:15
【问题描述】:

使用

mochaTest: {
   test: {
    options: {
      reporter: 'html-cov',
      captureFile: 'coverage.html' 
    },
    src: ['tests/*.js']
  }
}

在我的 gruntfile 中是给了我

“html-cov”记者未找到

警告。 如何在 html 文件中获取我的测试结果并查看它?

谢谢..

我也在使用grunt.loadNpmTasks('grunt-selenium-standalone') 任务。

【问题讨论】:

  • 你试过npm install html-cov吗?

标签: javascript testing gruntjs mocha.js gruntfile


【解决方案1】:

请查看以下链接:

https://github.com/pghalliday/grunt-mocha-test

这里有完整的例子,可能对你有帮助..

您可以使用 Mochawesome。它是用于 Javascript 测试框架 mocha 的自定义报告器。它会生成一个漂亮的 HTML/CSS 报告,帮助可视化您的测试套件。

首先,你需要安装插件:

npm install --save-dev mochawesome

然后你改变你的 grunt-mocha-test 记者:

mochaTest: {
    test: {
        options: {
            reporter: 'mochawesome', //You need to change this !
            colors: true,
            summery: true,
            captureFile: 'results.html',
            quiet: false,
            clearRequireCache: true
        },
        src: ['test/*spec.js'],
        excludes: ['plugins']
    },
    'travis-cov': {
        options: {
            reporter: 'travis-cov'
        }
    }
},

【讨论】:

  • @MeseleŞuki 完全没有问题
猜你喜欢
  • 1970-01-01
  • 2018-01-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-11-25
  • 1970-01-01
相关资源
最近更新 更多