开玩笑的报道:我怎样才能获得报道的总百分比? [英] Jest coverage: How can I get a total percentage of coverage?

查看:16
本文介绍了开玩笑的报道:我怎样才能获得报道的总百分比?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的 gitlab 管道中,我想将总百分比值发送到服务器.但是 jest --coverage 只给了我/coverage 中的这些大型报告文件.我似乎无法从中解析出总价值.我缺少参数吗?

In my gitlab pipeline I want to send the total percentage value to a server. But jest --coverage only gives me these large reporting files in /coverage. I can't seem to parse the total value out of it. Am I missing a parameter?

推荐答案

感谢 Teneff 的回答,我选择了coverageReporter="json-summary".

Thank's to Teneff's answer, I go with the coverageReporter="json-summary".

 jest --coverage --coverageReporters="json-summary" 

这会生成一个可以轻松解析的coverage-summary.json 文件.我直接从 json 中获取总值:

This generates a coverage-summary.json file which can easily be parsed. I get the total values directly from the json:

  "total": {
    "lines": { "total": 21777, "covered": 65, "skipped": 0, "pct": 0.3 },
    "statements": { "total": 24163, "covered": 72, "skipped": 0, "pct": 0.3 },
    "functions": { "total": 5451, "covered": 16, "skipped": 0, "pct": 0.29 },
    "branches": { "total": 6178, "covered": 10, "skipped": 0, "pct": 0.16 }
  }

这篇关于开玩笑的报道:我怎样才能获得报道的总百分比?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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