首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何将现有的伊斯坦布尔json文件转换为html

如何将现有的伊斯坦布尔json文件转换为html
EN

Stack Overflow用户
提问于 2017-10-12 20:17:29
回答 2查看 2.9K关注 0票数 2

我想转换从客户端获取的JSON格式的istanbul覆盖率报告文件为html格式。目前,我正在使用remap-istanbul来实现这一点,但实际上,该特定工具旨在为最初用不同语言(如typescript)编写的代码重新映射覆盖率数据。

所以我猜有没有更方便的方法来做同样的事情

EN

回答 2

Stack Overflow用户

发布于 2018-01-29 20:50:13

使用istanbul report html将现有的覆盖率数据从JSON转换为HTML:

代码语言:javascript
运行
复制
istanbul report html

默认情况下,上面的代码在当前目录(及其子目录)中查找以"coverage“开头和以".json”结尾的任何文件,并将报告输出到./coverage/目录。

要将特定文件转换为特定目录,请执行以下操作:

代码语言:javascript
运行
复制
istanbul report --include path/to/my-coverage-file.json --dir my-coverage-dir html

另一种仅从特定目录(例如,path/to中的所有JSON文件)读取覆盖率报告的方法如下所示,使用--root选项:

代码语言:javascript
运行
复制
istanbul report --root path/to --include=*.json --dir my-coverage-dir html

使用istanbul help report查看更多选项(下面是使用伊斯坦布尔0.4.5生成的):

代码语言:javascript
运行
复制
Usage: istanbul report <options> [ <format> ... ]

Options are:

      --config <path-to-config>
              the configuration file to use, defaults to .istanbul.yml

      --root <input-directory>
              The input root directory for finding coverage files

      --dir <report-directory>
              The output directory where files will be written. This defaults
              to ./coverage/

      --include <glob>
              The glob pattern to select one or more coverage files, defaults
              to **/coverage*.json

      --verbose, -v
              verbose mode


<format> is one of 
      clover  XML coverage report that can be consumed by the clover tool
      cobertura
              XML coverage report that can be consumed by the cobertura tool
      html    Navigable HTML coverage report for every file and directory
      json    prints the coverage object as JSON to a file
      json-summary
              prints a summary coverage object as JSON to a file
      lcov    combined lcovonly and html report that generates an lcov.info
              file as well as HTML
      lcovonly
              lcov coverage report that can be consumed by the lcov tool
      none    Does nothing. Useful to override default behavior and suppress
              reporting entirely
      teamcity
              report with system messages that can be interpreted with TeamCity
      text    text report that prints a coverage line for every file, typically
              to console
      text-lcov
              lcov coverage report that can be consumed by the lcov tool
      text-summary
              text report that prints a coverage summary across all files,
              typically to console

 Default format is lcov unless otherwise specified in the config file. In
 addition you can tweak the file names for various reports using the config
 file. Type `istanbul help config` to see what can be tweaked.

--input的值是一个全局模式。有关glob模式的更多文档,请参阅documentation at the glob package on NPM

票数 5
EN

Stack Overflow用户

发布于 2020-04-11 04:15:24

我猜由于伊斯坦布尔已经决定转向mono-repo,如果您使用mono-repo伊斯坦布尔,您将无法执行上述方法。

您可以按照这里的描述做一些事情:link。您可以生成一个覆盖图,然后传递它以生成所需格式的报告。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46709413

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档