2
votes

I have my project setup in WebStorm to transpile TypeScript into JavaScript etc. So I write my code as well as my tests in TypeScript.

When I run "Karma with coverage" in webstorm it all runs fine.

But, when for example a tests fails, the output keeps pointing to the javascript files. So when I click the failing test, it opens up the javascript file instead of the typescript file

enter image description here

Is there a way to integrate the mappings here as well?

My current preprocessor setup:

preprocessors: {
  'app/resources/**/*.ts': ['typescript'],
  //'app/resources/**/!(*spec).ts': ['sourcemap', 'coverage'],
  'app/resources/**/!(*spec).js': ['sourcemap', 'coverage'],
  'app/resources/**/*.html': ['ng-html2js']
},

I've taken a look at: https://www.npmjs.com/browse/keyword/karma-preprocessor and did a search for typescript. Basically I only find preprocessor that compile/transpile the typescript files, but that is something I already do in my test process. So I believe I can just leave the 'typescript' preprocessor out?

Thx!

2

2 Answers

1
votes

You should modify karma.conf and add 'coverage' for ts files. Something like follow:

preprocessors: {
            'test/*Test.ts':['typescript'],
            'src/*.ts':['typescript','coverage'],
        },