Howto point to typescript file instead of javascript file karma runner webstorm

梦想的初衷 提交于 2019-12-12 18:33:20

问题


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

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!


回答1:


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

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



回答2:


There is an open issue for this: https://youtrack.jetbrains.com/issue/WEB-13081



来源:https://stackoverflow.com/questions/33633043/howto-point-to-typescript-file-instead-of-javascript-file-karma-runner-webstorm

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!