JavaScript Karma - How to point to a source map for typescript coverage

I like to generate a coverage report for my typescript source files with karma-coverage. My unit tests are written in javascript and I'm using the Jasmine Test framework.

My folder structure looks like this:

node_modules/
app/
  app.js
  app.js.map
  app.ts
  components/
  controllers/
      SampleController.ts
  directives/
  filters/
  services/

unittests/
  karma.conf.js
  components/
  controllers/
      SampleControllerTest.js
  directives/
  filters/
  services/

My karma.conf.js

module.exports = function(config) {
  config.set({
    frameworks: ['jasmine'],
    plugins: [
          'karma-jasmine',
          'karma-ng-html2js-preprocessor',
          'karma-coverage',
          'karma-phantomjs-launcher',
          'karma-sourcemap-loader'

      ],
    preprocessors: {
        '../app/directives/controls/**/*Template.html' : [ 'ng-html2js' ],

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

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

    // web server port
    port: 9876,

    coverageReporter: {
          type : 'html',
          dir : 'coverage/'
      },
    // and some other stuff
  });
};

Currently my coverage report delivers sufficient metrics but not related to the single typescript files but the app.js.

I suppose that I either messed up something with the preprocessor config or that I need to specify the source map.

Anny hints?

Answer:1

I am trying to find all OPTION inside the SELECT using following JavaScript code. var temp = document.querySelectorAll("select"); console.log(temp[0].childNodes); and html markup is this <...

I am trying to find all OPTION inside the SELECT using following JavaScript code. var temp = document.querySelectorAll("select"); console.log(temp[0].childNodes); and html markup is this <...

  1. what is select text

So I've looked though some of the questions already asked about this issue and have not been able to find a solution that works for me. I am using Bootstrap (v 3.3.5) to create a navbar menu at the ...

So I've looked though some of the questions already asked about this issue and have not been able to find a solution that works for me. I am using Bootstrap (v 3.3.5) to create a navbar menu at the ...

I'm trying to create a simple accordion div that opens upwards. I have my accordion working nicely. But I now want to add plus and minus icons to the accordion. I have it somewhat working below on ...

I'm trying to create a simple accordion div that opens upwards. I have my accordion working nicely. But I now want to add plus and minus icons to the accordion. I have it somewhat working below on ...

  1. jquery collapse with icon
  2. jquery datatables with expandable accordion rows
  3. jquery table with expandable rows

I don't know why inner HTML is not working when I put it inside function but it works fine when I try the same in my console. Here is my code. (It is for character count.) for (var i = 0; i < ...

I don't know why inner HTML is not working when I put it inside function but it works fine when I try the same in my console. Here is my code. (It is for character count.) for (var i = 0; i < ...

  1. count number of words typed