How do you use Istanbul Code Coverage with transpiled Typescript?

后端 未结 5 2003
星月不相逢
星月不相逢 2021-02-01 14:15

I\'ve been reading articles on this all morning trying to get my environment setup correctly. But for some reason I\'m not getting it. My setup-

/app
    ... sou         


        
5条回答
  •  借酒劲吻你
    2021-02-01 14:49

    TL;DR: There is a tool: https://github.com/SitePen/remap-istanbul described as A tool for remapping Istanbul coverage via Source Maps

    The article on Sitepan describes it in more detail:

    Intern as well as other JavaScript testing frameworks utilise Istanbul for their code coverage analysis. As we started to adopt more and more TypeScript for our own projects, we continued to struggle with getting a clear picture of our code coverage as all the reports only included the coverage of our emitted code. We had to try to use the compilers in our minds to try to figure out where we were missing test coverage. We also like to set metrics around our coverage to let us track if we are headed the right direction.

    A couple of us started exploring how we might be able to accomplish mapping the coverage report back to its origins and after a bit of work, we created remap-istanbul, a package that allows Istanbul coverage information to be mapped back to its source when there are Source Maps available. While we have been focused on TypeScript, it can be used wherever the coverage is being produced on emitted code, including the tools mentioned above!

    How to use the tool with gulp: https://github.com/SitePen/remap-istanbul#gulp-plugin

提交回复
热议问题