npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dsh-test-report

v0.1.0

Published

test report toolkit for DeepSeek Harness: parse_junit (parse JUnit XML), parse_tap (parse TAP protocol), summarize (pass rate / slowest cases / failure clustering). Zero runtime dependencies, read-only.

Readme

dsh-test-report

DeepSeek Harness 的测试报告解析与摘要工具箱:parse_junit 解析 JUnit XML 测试报告、parse_tap 解析 TAP 协议输出、summarize 一键生成摘要(通过率 / 最慢用例 / 失败聚类)。零运行时依赖、只读优先,帮你在 CI 里快速读懂测试结果。

  • 源码:https://github.com/geeklei/dsh-plugins/tree/main/dsh-test-report
  • npm:https://www.npmjs.com/package/dsh-test-report

功能说明

测试跑完了,日志刷了一屏,真正的结论藏在两处:到底过了几个、失败为什么扎堆。本插件把两类最常见的测试报告格式收拾成一句话结论:

  • JUnit XML(parse_junit):解析 <testsuite> / <testcase> 结构,统计通过 / 失败 / 错误 / 跳过 / 耗时,识别 failure、error、skipped 子节点,并列出失败明细与最慢用例。内置轻量 XML 解析器,不依赖任何外部库。
  • TAP 协议(parse_tap):解析 TAP version、1..N 计划行、ok / not ok 测试点,兼容 # SKIP / # TODO 注释与诊断注释,统计通过 / 失败 / 跳过 / 待办 / 计划数。
  • 摘要总结(summarize):基于结构化结果或原始报告,算出通过率(去除跳过)、最慢用例 Top N、失败聚类(按失败原因合并同类,揪出扎堆问题)。既能直接传解析好的对象,也能让它先解析再总结。

默认只读不写文件,不会改动你的测试报告。

安装

npm install dsh-test-report

安装后在 cordis.patch.yml 中加入:

- insert:
    - id: test-report
      name: "dsh-test-report"

使用说明

三个工具都支持 content(直接传文本)或 path(文件路径)二选一。

parse_junit

解析 JUnit XML 测试报告。path 或 content 传入报告;max_size 限制文件大小、max_nodes 限制 XML 元素解析量、top 控制失败明细条数。

来源:E:\build\junit.xml
总用例 5|通过 2|失败 1|错误 1|跳过 1|耗时 1.38s
通过率(去除跳过):50%
测试套件:suiteA, suiteB

最慢 2 个用例:
1. testConnect(1.2s,error)
2. testMul(0.15s,passed)

失败聚类(按失败原因合并,共 2 类):
1. [1 个] expected 2 but got 3
2. [1 个] connection refused

失败/错误用例明细(前 2 条):
1. Math.testSub [failed]:expected 2 but got 3
2. Db.testConnect [error]:connection refused

parse_tap

解析 TAP 协议输出。支持 TAP version、1..N 计划行、ok / not ok、# SKIP / # TODO 注释。

来源:content 文本
总用例 5|通过 2|失败 1|错误 0|跳过 1|耗时 0s
通过率(去除跳过):50%
TAP 计划数:5

summarize

对测试报告做摘要。两种用法:

  • 直接传解析结果对象 report(字段:total / passed / failed / errors / skipped / duration / cases[]);
  • 传 format(junit 或 tap)+ content / path,让它先解析再总结。

top 控制最慢用例与聚类数量,slowest / clusters 可分别关闭最慢列表或失败聚类。

来源:content 文本
总用例 3|通过 2|失败 1|错误 0|跳过 0|耗时 2s
通过率(去除跳过):66.7%
最慢 1 个用例:
1. 某用例(1.9s,failed)
失败聚类(按失败原因合并,共 1 类):
1. [1 个] 超时

典型场景

  • CI 结果速览:流水线结束把 JUnit 报告丢给 parse_junit,一句话拿到通过率与失败清单。
  • 失败聚类分析:几十个用例一起红,summarize 按失败原因合并,立刻看出是「同一处代码改坏」还是「环境级故障」。
  • 性能门禁:parse_junit 列出最慢用例,定位拖慢回归的瓶颈用例。
  • TAP 兼容:Perl / Rust / 一些 Node 测试器的 TAP 输出,用 parse_tap 统一成结构化结果。
  • 多格式统一:仓库里 JUnit 与 TAP 混用,summarize 统一口径出摘要。

安全边界

  • 只读优先:三个工具纯解析、零写入,不落盘不修改报告。
  • 不访问网络:全部本地解析,无外部请求。
  • 解析有界:max_size 跳过超大文件;max_nodes 限制 XML 元素解析量;max_chars 截断过长输出。
  • 格式为子集:JUnit 与 TAP 实现众多,本插件覆盖主流结构与标记;非常规扩展字段可能被忽略(不报错)。
  • 通过率口径:去除跳过(total - skipped)做分母,与多数 CI 一致;todo 计入总数但不计入通过/失败。

其他插件集成说明

| 协作插件 | 集成方式 | |---|---| | dsh-code-metrics | test-report 看测试结果,code-metrics 看测试代码复杂度,配对评估质量 | | dsh-doc-outline | 用 doc-outline 维护本插件 README 结构,或用它整理测试文档 | | dsh-markdown-lint | 测试失败报告落成 md 时,markdown-lint 保证格式规范 | | dsh-template-render | 把 summarize 结果套进团队模板,生成测试周报 | | dsh-log-parse | 失败聚类与日志时间线结合,定位根因 |

版本说明

  • 0.1.0(2026-10-12):初始版本。
    • parse_junit:内置轻量 XML 解析器,解析 testsuite/testcase,识别 failure/error/skipped,输出统计 + 失败明细 + 最慢用例
    • parse_tap:解析 TAP version / 计划行 / ok·not ok / # SKIP / # TODO / 诊断注释
    • summarize:通过率(去除跳过)+ 最慢用例 Top N + 失败聚类(按失败原因合并)
    • 支持 content / path 双入口;只读优先、有界解析、输出截断

RoadMap

v0.2(计划)

  • parse_junit 支持嵌套 system-out / properties 提取
  • summarize 增加 output: "json" 机器可读输出
  • 失败聚类支持按「异常类型」分组(从堆栈首行识别)

v0.3(展望)

  • 增加 parse_json_report(通用 JSON 测试报告,如部分框架的汇总)
  • 支持多文件批量汇总(一个目录下多份 JUnit 报告合并)
  • 与 CI 联动输出「环比通过率」变化

FAQ

Q:通过率为什么用「去除跳过」算? 跳过的用例不是「跑了没通过」,是「被显式跳过」。把它当分母会不公平地拉低通过率。所以用 总用例 - 跳过 做分母,和多数 CI 平台口径一致。todo 同理计入总数但不当失败。

Q:parse_junit 需要装 XML 库吗? 不需要。内置一个轻量 XML 词法与建树解析器,零运行时依赖,够覆盖 JUnit 报告的主流结构。只做「能读懂报告」这件事,不追求通用 XML 的全部特性。

Q:失败聚类是怎么聚的? 把所有 failed / error 用例按失败消息(message 属性 + 堆栈首行文本)分组,同一条失败原因的归一类,并列出每类涉及的前几个用例名。这样一次看清「是同一处坏了 3 个用例」而不是 3 个孤立失败。

Q:最慢用例的时间从哪来? JUnit 从每个 <testcase> 的 time 属性取;TAP 本身不含耗时,所以 parse_tap 的用例耗时统一为 0,最慢列表对 TAP 为空。

Q:summarize 的 report 参数要什么结构? { total, passed, failed, errors, skipped, duration, cases: [{ name, status, time, message }] }。cases 是数组,status 取 passed / failed / error / skipped / todo 之一。你也可以省掉,直接给 format + content / path 让它自己解析。

Q:报告里有很多非标准 XML 标记会崩吗? 不会。轻量解析器对注释、CDATA、声明、自闭合标签都做了容错,遇到不认识的结构只是忽略对应元素,不会中断整个解析。

源码与发布地址

  • 源码:https://github.com/geeklei/dsh-plugins/tree/main/dsh-test-report
  • npm:https://www.npmjs.com/package/dsh-test-report

许可证

MIT