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