1

I am having problems getting Istanbul to output it's HTML report to the directory specified in my Karma config. It currently outputs the main index.html in the correct directory(reports/coverage) but the detailed html child pages are output to the same directory as the source file(www/js/...). It is the same problem described here and here, but after trying the suggested solution the problem persists.

This is the contents of my karma config file:

basePath: './',

frameworks: ['jasmine'],

files: [
  'www/lib/angular/angular.js',
  'www/js/*.js',
  'www/js/services/*.js',
  'www/js/controllers/*.js',
  'www/lib/angular-mocks/angular-mocks.js',
  'tests/**/*test.js',
  'tests/test-data/*.json'
],

plugins: [
  'karma-jasmine',
  'karma-coverage',
  'karma-phantomjs-launcher',
  'karma-ng-json2js-preprocessor'
],

preprocessors: {
  'www/js/**/*.js': ['coverage'],
  'tests/**/*.json':         ['ng-json2js']
},

ngJson2JsPreprocessor: {
  stripPrefix: 'tests/test-data/',
  prependPrefix: 'served/'
},

reporters: ['progress', 'coverage'],

port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['PhantomJS'],
singleRun: true,

coverageReporter: {
  // Common output directory
  dir: 'coverage',
  reporters: [
    { type: 'text-summary'},
    { type: 'html', subdir:'report-html' }
  ]
}

Suggestions on how to resolve this so all of the coverage files are placed into the reports/coveragedirectory would be much appreciated. Thanks.

Community
  • 1
  • 1

1 Answers1

2

I have wrestled with this myself and found that I had to be a little more explicit in the reporters portion of the coverageReporter config by specifying the directory and the subdirectory for each.

coverageReporter: {
  reporters: [
    { type: 'text-summary', dir: 'coverage/' },
    { type: 'html', dir: 'coverage/', subdir: 'report-html' }
  ]
}

I can't explain why that combination ultimately worked for me, but after multiple permutations that was what I ended up at.

tokkov
  • 2,959
  • 1
  • 13
  • 9