2014-09-20 134 views
1

這裏是我的Gruntfile:將測試日誌保存到磁盤?

module.exports = function(grunt) { 

    // Project configuration. 
    grunt.initConfig({ 
    pkg: grunt.file.readJSON('package.json'), 
    mochaTest: { 
     test: { 

     options: { 
      reporter: 'spec', 
      clearRequireCache: true, 
      require: ['./index.js'] 
     }, 
     src: ['test/**/*.coffee'] 
     }, 
     report: { 

     options: { 
      reporter: 'markdown', 
      clearRequireCache: true, 
      require: ['./index.js'] 
     }, 
     src: ['test/**/*.coffee'], 
     dest: './FEATURES.md' 
     } 

    }, 
    watch: { 
     test: { 
     options: { 
      spawn: false, 
     }, 
     files: ['src/**/*.coffee', 'test/**/*.coffee'], 
     tasks: ['coffee:main', 'mochaTest'] 
     } 
    }, 
    coffee: { 

     main: { 
     options: { 
      bare: true 
     }, 

     files: [{ 
      expand: true, 
      cwd: "./src", 
      src: ["**/*.coffee"], 
      dest: "./lib", 
      ext: ".js" 
     }] 
     }, 


    } 
    }); 
    grunt.loadNpmTasks('grunt-contrib-coffee'); 
    grunt.loadNpmTasks('grunt-contrib-watch'); 
    grunt.loadNpmTasks('grunt-mocha-test'); 

    // Default task(s). 
    grunt.registerTask('default', ['coffee:main', 'mochaTest:test', 'watch']); 
    grunt.registerTask('test', ['coffee:main', 'mochaTest:test']); 
    grunt.registerTask('report', ['coffee:main', 'mochaTest:report']); 

}; 

當我運行grunt對其進行測試,並報告手錶作爲規範,但是當我運行grunt report它告訴我在降價的輸出,雖然沒有文件在項目的根目錄中創建。是否有可能讓markdown記者在代碼標籤中輸出coffeescript而不是js?有沒有辦法通過y代碼刪除任何記錄的輸出?

回答

1

The grunt-mocha-test插件沒有dest選項。我認爲你正在尋找captureFile

要從控制檯刪除所有輸出,您可以將安靜設置爲true。

這裏是你的更新mochaTest:report

report: { 
    options: { 
    reporter: 'markdown', 
    clearRequireCache: true, 
    require: ['./index.js'], 
    quiet: true, 
    captureFile: 'FEATURES.md' 
    }, 
    src: ['test/**/*.coffee'] 
} 

爲了您的第二個問題,您可以查看所有的摩卡記者here和更簡潔的列表here的名單,但沒有咖啡的呢。

+0

非常感謝。最高的問題。有沒有辦法輸出咖啡?* – Vinz243 2014-09-24 10:33:30

+0

你想用** mochaTest **輸出'coffee'而不是'markdown',或者這是你想要實現的東西嗎? – 2014-09-24 10:35:21

+0

GH圍欄代碼之間的輸出代碼爲js。我想在咖啡:) – Vinz243 2014-09-24 10:36:16