从 JavaScript 代码覆盖中排除函数(不是整个文件) [英] Exclude function (not an entire file) from JavaScript code coverage

查看:17
本文介绍了从 JavaScript 代码覆盖中排除函数(不是整个文件)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Jasmine 创建一些单元测试,我使用的测试运行器是 Karma.我还在使用 karma-coverage 插件检查这些测试规范的代码覆盖率.

I'm creating some unit tests with Jasmine and the test runner I'm using is Karma. I'm also checking the code coverage of these test specs with the karma-coverage plugin.

我想知道是否有任何方法可以从代码覆盖范围本身以及 Karma 报告(实际上是伊斯坦布尔)中排除某些功能.我在想,如果第一个解决了,那么第二个也解决了.

I was wondering if there's any way of excluding certain functions from the code coverage itself and also from the Karma report (Istanbul actually). I'm thinking that if the first one is solved then so is the second.

很确定没有明显的方法可以做到这一点,因为我也看过伊斯坦布尔(业力覆盖使用它)但也许你们中的一些人以前遇到过这种情况.

Pretty sure there's no obvious way of doing this, as I've looked in Istanbul as well (karma-coverage uses it) but maybe some of you run into this before.

推荐答案

Istanbul 背后的人似乎增加了对忽略覆盖分析中特定代码部分的支持.真的很有用!

It appears that the guy behind Istanbul has added support for ignoring specific sections of code from coverage analysis. Really useful!

更多:https://github.com/gotwarlost/istanbul/blob/master/ignoring-code-for-coverage.md

这篇关于从 JavaScript 代码覆盖中排除函数(不是整个文件)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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