2017-05-05 3 views
0

カーマを使用してJSユニットテストケースとイスタンブールを作成し、カバレッジレポートを取得しています。 マイkarma.conf.jsファイルは以下の通りである - 私はタイプ 'HTML' と 'lcov' を使用したい。ここcoverageReporter内部karma.conf.js内に複数のカバレッジレポートタイプを使用したい

// karma.conf.js 
module.exports = function(config) { 
    config.set({ 
    files: [ 
     'test/**/*.js' 
    ], 

    // coverage reporter generates the coverage 
    reporters: ['progress', 'coverage'], 

    preprocessors: { 
     // source files, that you wanna generate coverage for 
     // do not include tests or libraries 
     // (these files will be instrumented by Istanbul) 
     'test/**/*.js': ['coverage'] 
    }, 

    // optionally, configure the reporter 
    coverageReporter: { 
     type : 'html', 
     dir : 'coverage/' 
    } 
    }); 
}; 

。これを行うには、私は以下のようにそれを変更 -

coverageReporter:{ タイプ: 'HTML'、 'lcov'、 DIR: 'カバレッジ/' }

をその後、私はkarma start karma.conf.jsを実行しましたが、例外の下になって - -

C:\abc\npm-1.4.9>karma start karma.conf.js 
05 05 2017 16:57:00.369:ERROR [config]: Invalid config file! 
    C:\abc\npm-1.4.9\karma.conf.js:45 
     type : 'html','lcov', 
         ^
SyntaxError: Unexpected token , 
    at createScript (vm.js:53:10) 
    at Object.runInThisContext (vm.js:95:10) 
    at Module._compile (module.js:543:28) 
    at Object.Module._extensions..js (module.js:580:10) 
    at Module.load (module.js:488:32) 
    at tryModuleLoad (module.js:447:12) 
    at Function.Module._load (module.js:439:3) 
    at Module.require (module.js:498:17) 
    at require (internal/module.js:20:19) 

ご協力いただきまして誠にありがとうございます。

答えて

0

あなたはcoverageReporterプロパティについては、この構造の構成を使用する必要があります。

coverageReporter: { 
    // specify a common output directory 
    dir: 'coverage/', 
    reporters: [ 
    // reporters not supporting the `file` property 
    { type: 'html', subdir: '.' }, 
    { type: 'lcov', subdir: '.' }, 

    ] 
} 

これはカルマ・カバレッジのreadmeに記載されています。

+0

をこれが働いていたが、1件の副作用があります。私はkarma.conf.js(ChromeとPhantomJs)の2つのブラウザについて言及しています。通常、レポートはブラウザごとに別々に生成されますが、設定の上はブラウザの設定を無視しています。これについての任意の考え??? - –

0

は、以下の例を試してみてください。

coverageReporter: { 
    reporters: [ 
     {type: 'html', dir: 'html-coverage'}, 
     {type: 'lcov'} 
    ] 
} 
+0

Ohh has it ..私はいつも、それぞれのレポータータイプの中括弧の中にタイプとディレの組み合わせでこれらを追加する必要があります。私たちがディレクトリを何も言及していない場合、デフォルトでそれは「カバレッジ」ディレクトリを作成し、その中のすべてを埋めることに気付きました。ありがとう、@ Vlad !!! –

+0

@ArvindMauryaあなたは大歓迎です:) –

関連する問題