【问题标题】:grunt-mocha-test JSON reporter to a file without console.logsgrunt-mocha-test JSON 报告器到没有 console.logs 的文件
【发布时间】:2015-12-23 00:14:40
【问题描述】:

我正在尝试使用 grunt-mocha-test 将所有测试结果保存在 JSON 文件中...
我只是不知道如何摆脱 console.log 输出,我只需要 JSON。
这是我的conf:

 mochaTest: {
158             src: ['app/tests/middleware/**/*.js'],
159             options: {
162                 reporter: 'json',
164                 captureFile: './app/tests/results/mochaResult.json',
165                 //quiet:'true',
166                 require: 'server.js'
167             }
168         },

这是一个输出示例:

 2 ^[[7m Application loaded using the "test" environment configuration
  3 ^[[0m
  4 connecting to mongodb...
  5 name: localhost
  6 app started on port 3000
  7 successful connection to redis server
  8 {
  9   "stats": {
 10     "suites": 1,
 11     "tests": 5,
 12     "passes": 5,
 13     "pending": 0,
 14     "failures": 0,
 15     "start": "2015-12-23T00:01:43.968Z",

我错过了什么?有没有其他方法可以解决这个问题?

【问题讨论】:

    标签: json testing gruntjs automated-tests mocha.js


    【解决方案1】:

    请尝试以下解决方法:

    grunt.log.header = function () {};
    

    我发现this 链接可能包含有用的信息。还有一些软件包可以帮助解决这个问题,特别是grunt-log-headers。让我知道这是否有效!

    【讨论】:

    • 最终我想要的是一个包含所有结果的 JSON 文件,而不是之前的 console.logs。是的, quiet 选项确实将 console.logs 包含在文件中。就是上面的例子
    猜你喜欢
    • 2014-03-16
    • 1970-01-01
    • 2023-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多