← 返回 Skills 市场
vuact

jest-unittest

作者 vuact · GitHub ↗ · v1.0.3 · MIT-0
cross-platform ⚠ suspicious
133
总下载
1
收藏
0
当前安装
4
版本数
在 OpenClaw 中安装
/install jest-unittest
功能描述
单元测试 Skills 集合。当用户提到单测、单元测试、覆盖率、单测覆盖、单测失败、单测报错、修复单测、补充测试、覆盖率不足、覆盖率100%、运行单测、组件测试等关键词时触发。 包含三个子技能:unittest-checker(覆盖率检测)、unittest-completer(自动补全测试至100%)、unit...
使用说明 (SKILL.md)

Unit Test System

根据用户意图路由到对应子技能。

配置

配置文件按项目隔离,存放在 .temp/projects/\x3Chash>/ 下(hash 由项目根路径计算):

  • source.json — 用户配置的 jest 配置文件路径
  • config.json — 由 reload.cjs 自动生成的完整配置

各子技能的脚本启动时会自动校验配置和环境。如果返回 error 字段,根据 type 处理:

  • config_error → 按 hint 帮用户配置 source.json(路径见错误信息中的 sourceJsonPath),执行 node scripts/reload.cjs 生成配置,然后重试
  • env_error → 根据 error 信息排查环境问题,解决后重试

用户主动要求 reload 时,直接执行 node scripts/reload.cjs

多项目支持

本 skill 支持在多个项目间使用而不产生配置冲突。每个项目的 source.jsonconfig.json 独立存放在 .temp/projects/\x3Chash>/ 下,切换项目时自动识别。

路由规则

用户意图 路由到
查看覆盖率、检查哪些单测覆盖率未达标、覆盖率报告 unittest-checker
补充测试、让单测覆盖率达到100%、写单测 unittest-completer
单测报错、单测失败、修复单测、诊断单测问题 unittest-doctor

严禁事项

  • 严禁手动编辑 config.json,必须通过 reload.cjs 生成。
  • 严禁修改项目的 jest 配置文件来适配本 skill。
  • 严禁手动运行 jest 命令来替代脚本,脚本参数由 config.json 提供。

Sub-skills

Sub-skill 功能
unittest-checker 运行测试并分析覆盖率,输出未达标组件列表
unittest-completer 指定组件名,自动补充测试直到四项覆盖率全部100%
unittest-doctor 运行测试,诊断失败和console警告,支持自动修复
安全使用建议
这个技能看起来确实会运行 Jest、生成/解析 coverage,并自动写入测试文件以尝试把覆盖率补到 100%,功能与描述一致。但有几点在使用前务必注意: 1) 在启用前备份或在单独分支/沙箱仓库运行:completer 会编辑测试文件(并可能在极少数情况下修改源文件),以免意外破坏主分支代码。 2) 检查并确认 source.json(jestConfigPath)的内容:脚本把该路径直接拼到 shell 命令里,错误或恶意的路径字符串可能导致命令注入风险。不要把不可信的字符串写入 source.json。最好由你手动填写或审查该文件后再运行 reload。 3) 审阅生成的 config.json 与 .temp 内容:技能将 per-project 配置和覆盖率产物放在 skill 的 .temp 下(skill 包目录),这可能与你预期的项目结构不同,确认路径不会暴露敏感信息或被误提交。 4) 网络/依赖行为:脚本使用 npx 和可能触发 npm 下载,确保在可控网络环境下运行,或事先在项目中安装好依赖(本地 jest),以减少远程包拉取。 5) 命令注入风险:如果你担心安全,审查脚本(已经包含在包内)并/或将命令执行改为使用参数化 APIs(或手动运行生成的命令)来避免 shell 拼接风险。 如果你愿意,我可以帮你审阅具体的 source.json/config.json 示例、或者把这些脚本逐条解释清楚并指出如何在你的环境中安全运行。
功能分析
Type: OpenClaw Skill Name: jest-unittest Version: 1.0.3 The skill bundle implements a complex unit testing automation system that is prone to command injection vulnerabilities. Specifically, `scripts/reload.cjs` and `sub-skills/unittest-doctor/scripts/test-error-reporter/index.cjs` construct shell commands by concatenating strings from user-controlled or project-provided configuration files (like `source.json` and Jest config files) and execute them using `execSync` (with `shell: true` in some cases). While these capabilities are aligned with the stated purpose of running tests and checking coverage, the lack of input sanitization on configuration paths allows for potential arbitrary code execution if the agent is manipulated into using a malicious configuration string.
能力评估
Purpose & Capability
技能名与描述(覆盖率检测、自动补全测试、诊断修复)与包含的脚本/子技能功能对齐;所需权限(读写测试文件、运行 jest/npx)与功能预期相符。唯一偏差是脚本把 per-project 配置(source.json/config.json)放在 skill 包目录下的 .temp 中,而不是直接放在项目目录,这可能令用户意外地将项目相关配置保存在 skill 安装目录。
Instruction Scope
运行时的脚本会:读取项目 jest 配置和源码、运行 npx jest(通过 execSync / shell)、解析 coverage 与错误、并在 completer 中使用 Edit/Write/ MultiEdit 修改测试文件(在明确告知下才会修改源文件)。风险点:命令字符串以简单拼接方式构建并传入 shell(例如 testCommand 包含来自 source.jestConfigPath 与其他配置字段),如果这些字段被恶意或意外设置,可能出现命令注入;脚本也会读取/写入项目文件,带来潜在的破坏性改动(虽然文档声明优先修改测试文件)。总体上操作超出“只读分析”的范围,但与“自动补全/修复单测”的目的有关联。
Install Mechanism
该 skill 是 instruction-only(无安装规范),包含本地脚本文件。没有从远程 URL 下载或在安装时执行未知二进制文件,风险相对较低。
Credentials
技能不请求任何环境变量或外部凭证——这与其本地运行测试/修改文件的目的相称。需要注意的是,它会调用 `npx`/`git`,这些工具可能会访问网络或本地工具链,且运行 `npx` 会在需要时从 npm 拉取包,这是预期行为但有网络依赖。
Persistence & Privilege
技能不会设置 always:true,也不请求持久凭证,但会在 skill 包目录生成 `.temp/projects/<hash>/` 和 coverage 报告文件,且允许通过 agent 的 Edit/Write 权限自动修改测试文件(并在特定情况下修改源文件)。自动修改代码是该技能的核心功能,但对不熟悉行为的用户具有潜在破坏性,应该在受控分支或备份下运行。
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install jest-unittest
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /jest-unittest 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.3
- Added multi-project support: each project's configuration files are now isolated under .temp/projects/<hash>/ to prevent conflicts. - Updated configuration instructions and error handling to reflect the new per-project config system. - Added scripts/resolve-project.cjs; removed config.json and source.json from the root (now managed per project). - Documentation updated to explain config paths, hash calculation, and automatic project detection.
v1.0.2
- Version bump to 1.0.2 with no file or logic changes. - No updates detected in documentation or code.
v1.0.1
- 移除了 .temp/coverage 目录下的所有 coverage-final.json 文件 - 不再包含临时覆盖率报告数据 注:.temp 文件不要纳入版本管理
v1.0.0
Initial release of jest-unittest skill. - Provides unit test assistance triggered by related keywords. - Routes user requests to one of three sub-skills: unittest-checker (coverage analysis), unittest-completer (auto-complete coverage to 100%), unittest-doctor (diagnose and fix test failures). - Includes automated configuration and environment validation during startup. - Highlights strict usage guidelines to ensure consistency and reliability. **Reload on first use**: On the very first run you should execute a reload (`node scripts/reload.cjs`). More generally, whenever the file referenced by `jestConfigPath` in `source.json` has been modified, a reload is recommended so that `config.json` stays in sync with the actual Jest configuration.
元数据
Slug jest-unittest
版本 1.0.3
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 4
常见问题

jest-unittest 是什么?

单元测试 Skills 集合。当用户提到单测、单元测试、覆盖率、单测覆盖、单测失败、单测报错、修复单测、补充测试、覆盖率不足、覆盖率100%、运行单测、组件测试等关键词时触发。 包含三个子技能:unittest-checker(覆盖率检测)、unittest-completer(自动补全测试至100%)、unit... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 133 次。

如何安装 jest-unittest?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install jest-unittest」即可一键安装,无需额外配置。

jest-unittest 是免费的吗?

是的,jest-unittest 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

jest-unittest 支持哪些平台?

jest-unittest 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 jest-unittest?

由 vuact(@vuact)开发并维护,当前版本 v1.0.3。

💬 留言讨论