2015-10-29 23 views
5

私はカルマに関して、ブラウザカバレッジでいくつかの助けが必要です。カルマカバレッジで正しい結果が表示されない

https://github.com/jotaoncode/web-istanbul

私のカバレッジの結果は次のとおりです: Results of coverage

テストは唯一の機能インデックス上で実行されます私は、私がここで実行しているテストとのレポを作成しました。しかし、あなたが見ることができるように、結果は100%であり、緑色のファイルの最初の行だけをマークします。

イスタンブールでカバレッジ値が正しく表示されていることがわかりました。テストとソースは変更しましたが、何も変更しませんでした。あなたがテストを実行した場合、あなたはそれが実際には正常に動作しますが、カバレッジレポートが正しくないことがわかります

module.exports = function(config) { 
    config.set({ 
    //logLevel: 'LOG_DEBUG', 

    reporters: ['spec', 'coverage'], 

    // Continuous Integration mode 
    // if true, Karma captures browsers, runs the tests and exits 
    singleRun : true, 

    autoWatch : false, 

    // base path that will be used to resolve all patterns (eg. files, exclude) 
    basePath: '', 

    port: 9876, 

    // frameworks to use 
    // available frameworks: https://npmjs.org/browse/keyword/karma-adapter 
    frameworks: [ 
     'mocha', 
     'browserify' 
    ], 

    files: [ 
     'src/**/*.js', 
     'test/*.js' 
    ], 

    // list of files to exclude 
    exclude: [], 

    preprocessors: { 
     'src/**/*.js': ['browserify', 'coverage'], 
     'test/**/*.js': ['browserify'] 

    }, 

    coverageReporter: { 
     reporters: [ 
     { type: 'html' }, 
     { type: 'text' }, 
     { type: 'lcovonly' } 
     ], 
     instrumenterOptions: { 
     istanbul: { 
      noCompact: true 
     } 
     }, 
     instrumenter: { 
     'test/**/*.js': 'istanbul' 
     }, 
     includeAllSources: true 
    }, 


    // enable/disable colors in the output (reporters and logs) 
    colors: true, 

    // start these browsers 
    // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher 
    browsers: [ 
     'PhantomJS2' 
    ] 

    }); 
}; 

は、私はまた、このカルマの構成を有しています。

+0

あなたがカバレッジを実行する前にあなたは痩せていますかこれらの結果は、コード以外のものに対して実行されているように見えます。ソースマップが完全には到達していない可能性があります。 – ssube

+0

@ssubeいいえソースマップについては、おそらくソースマップを作成していたカルマコンフィギュレーションファイルでbrowserify {debug:true}を実行しているので、アクティブな場所のソースマップに関してコードを細分化していません。私は削除し、ソースコードのカバレッジを表示せずに同じ方法で作業を続けます。 –

答えて

1

は、私はこの問題にコメントとしてこれが解決されたいくつかの研究を行った後:

https://github.com/karma-runner/karma-coverage/issues/16

私はbrowserify-イスタンブール使用し、今カバレッジレポートが正常に動作している:)

enter image description here

関連する問題