业力,覆盖率报告与Webpack结合 [英] Karma, coverage report combined with webpack

查看:114
本文介绍了业力,覆盖率报告与Webpack结合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置了业力以及正在运行的覆盖率工具-但由于我也在使用webpack,因此覆盖率报告使用的是webpack创建的捆绑代码.

I have karma set up along with the coverage tool which is working - but as I'm also using webpack, the coverage report is using the bundled code that webpack has created.

例如: 我有一个包含外部库的Typescript文件,因此为了运行该文件,需要webpack.然后,Webpack将该文件包含到已编译的JS中. 这意味着当我获得覆盖率报告时,它的百分比很低,因为我没有测试现在包含的外部文件.

For example: I have a Typescript file that includes an external library, so in order for that file to run it needs webpack. Webpack then includes that file into the compiled JS. This means that when I get the coverage report its % is low as I'm not testing the external file which has now been included.

preprocessors: {
            './src/**/*.ts': ['webpack', 'coverage']
        },

如果我删除webpack部件或以其他方式放置数组(['coverage','webpack']),它将失败.

If I either remove the webpack part or place the array the other way around ( ['coverage', 'webpack']) it fails.

因此,我不确定如果没有webpack和已编译的TS-> JS文件,我追求的目标是否会通过测试.有点像我希望报告分两步完成.

So, I'm not sure if what I'm after is possible as without webpack and compiled TS -> JS file will fail the tests. Its a bit like I want the reporting done in two steps.

  1. 针对捆绑的代码运行测试并报告.
  2. 检查已运行的测试,并与非捆绑文件进行比较以获取准确的覆盖率报告.

如果对任何答案都有帮助,我也使用Jasmine作为框架.

If it makes a difference to any answer, I'm also using Jasmine as a framework.

推荐答案

花了一段时间-但我发现了一个很好的示例,可以满足我的需求和需求. https://github.com/AngularClass/angular2-webpack-starter 这是打字稿,因果报应,覆盖范围和内容; Webpack.

Took a while - but I found a good example that worked with what I wanted and how I wanted it. https://github.com/AngularClass/angular2-webpack-starter This does Typescript, Karma, Coverage & Webpack.

也- https://angularclass.github.io/angular2-webpack-starter/

这篇关于业力,覆盖率报告与Webpack结合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆