Grunt-template-jasmine-istanbul缺少dir错误

时间:2014-05-18 16:27:37

标签: gruntjs jasmine istanbul

我安装了grunt插件grunt-template-jasmine-istanbul

npm install grunt-template-jasmine-istanbul --save-dev

并添加到Gruntfile.js,如下所示:

coverage: {
    src: ['app/scripts/**/*.js'],
    options: {
        specs: ['test/**/*.js'],
        template: require('grunt-template-jasmine-istanbul'),
        templateOptions: {
            coverage: 'test/coverage/coverage.json',
            report: [
               {type:'html',options: {dir: 'test/coverage/html'}},
               {type:'text',options: {dir: 'test/coverage/text'}},
               {type:'text'},
            ],
            thresholds: {
                lines: 75,
                statements: 75,
                branches: 75,
                functions: 90
            }
        }
    }
},

但是在运行测试时,会在测试/覆盖率文件夹中显示以下警告并且没有报告

my@computer:/share/angularjs-gs$ grunt test:coverage
Running "coverage" task
Warning: "dir" option is required. Use --force to continue.

Aborted due to warnings.

我还创建了test / coverage / html和test / converage / text文件夹。我还查看了插件作者的代码,但无法找到任何解决方案:https://github.com/maenu/grunt-template-jasmine-istanbul-example/blob/connect/Gruntfile.js

1 个答案:

答案 0 :(得分:0)

我发现它,必须用jasmine包装覆盖对象,它可能用作jasmine插件但spec和src属性似乎是多余的。

  jasmine: {
    coverage: {
        src: ['app/scripts/**/*.js'],
        options: {
            specs: ['test/**/*.js'],
            template: require('grunt-template-jasmine-istanbul'),
            templateOptions: {
                coverage: 'test/coverage/coverage.json',
                report: [
                   {type:'html',options: {dir: 'test/coverage/html'}},
                   {type:'text',options: {dir: 'test/coverage/text/'}},
                   {type:'text-summary'}
                ],
                thresholds: {
                    lines: 75,
                    statements: 75,
                    branches: 75,
                    functions: 90
                }
            }
        }