私は解決策としてgrunt-browserify
+ browserify-istanbul
+ grunt-contrib-jasmine
+ grunt-template-jasmine-istanbul
を使用しています。このソリューションには、browserify
を使用してソースファイルを構築するときにサードパーティライブラリも除外されています。
- 音源コード
- ランテスト
:
は、最初のコードを表示し、私は後で、イスタンブールカバレッジレポートを生成する
grunt.initConfig({
browserify: {
// build specs using browserify
specs: {
src: ["spec/**/*Spec.js"],
dest: "spec/build/specs.js",
options: {
debug: true
}
},
// build source files using browserify and browserify-istanbul
dev: {
options: {
debug: true,
browserifyOptions: {
standalone: 'abc'
},
transform: [['browserify-istanbul', {
ignore: ['**/node_modules/**'], // ignore third party libs
defaultIgnore: true
}]]
},
src: ['abc.js'],
dest: 'dist/abc.js'
}
},
connect: {
server: {
options: {
port: 7000
}
}
},
// test using jasmine, generate coverage report using istanbul
jasmine: {
coverage: {
src: ['dist/abc.js'],
options: {
junit: {
path: 'bin/junit'
},
host: 'http://localhost:7000/',
specs: 'spec/build/specs.js',
keepRunner: true,
summary: true,
template: require('grunt-template-jasmine-istanbul'),
templateOptions: {
replace: false, // *** this option is very important
coverage: 'bin/coverage/coverage.json',
report: [
{
type: 'html',
options: {
dir: 'spec/coverage/html'
}
}]
}
}
}
}
grunt.registerTask('specs', ['browserify:specs', 'browserify:dev', 'connect', 'jasmine']);
手順は三つに結論することができる説明します
- カバレッジレポートを生成する
当社のソリューションで
は、私たちはあなたの機器コードがbrowserify建物のステップでできるようになるステップ1でbrowerify-istanbul
、grunt-contrib-jasmine
とrunt-template-jasmine-istanbul
ステップ2でと3
browserify-istanbul
を使用して、このように、我々は簡単にサードパーティのLIBSを無視することができます。しかし、grunt-template-jasmine-istanbul
は再びコードを記入します。これを避けるには、オプションでreplace
〜false
を設定します。
参考文献:
- Istanbul steps
- broswerify-istanbul
- grunt-contrib-jasmine
- grunt-template-jasmine-istanbul -
replace
オプション
は、あなたはこの1つを把握しましたか?現時点でガード・プロジェクトで働いていますか? –
この質問が答えを出して3年間ここにあったとはどういう意味ですか... – QueueHammer