Skip to Content
DocumentationEcosystem@canyonjs/report

@canyonjs/report

Source

一个覆盖率报告器,适配istanbul-reports 接口

安装

npm install --save-dev @canyonjs/report

使用

该报告器适配istanbuljs报告器接口,所以支持各种常见的测试框架的覆盖率报告生成,以vitest为例

import { defineConfig } from "vitest/config"; export default defineConfig({ test: { coverage: { provider: "v8", reporter: ["@canyonjs/report"], }, }, });

配置

Important

支持传入git diff,生成变更代码覆盖率报告!默认读取diff.txt文件内容。在CI中集成请查看 @canyonjs/git-diff

import { defineConfig } from "vitest/config"; export default defineConfig({ test: { coverage: { provider: "v8", reporter: [ "json", [ "@canyonjs/report", { diff: diff, // 支持git diff字符串、路径 }, ], ], }, }, });

输出

  • index.html,单个html文件,易于传输/部署或直接在任何位置打开。
  • data/report-data.js,对应压缩过的覆盖率数据及源码内容。
  • js、css等静态资源。

例子

测试框架示例链接
Vitestreport-html-vitest 
Jestreport-html-jest 
RSTestreport-html-rstest 
Mochareport-html-mocha 
Test Runnerreport-html-test-runner