问题
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