@toby1123yjh/test-cli
v0.1.16
Published
AI-powered E2E testing tool with natural language test case generation
Readme
test-cli
AI 驱动的 E2E 测试 CLI:通过 /generate//update 生成可运行的测试脚本,通过 /run 执行并输出 Markdown/HTML 报告。
安装
npm install -g @toby1123yjh/test-cli
- 用官方 npmjs 装:npm i -g @toby1123yjh/test-cli@latest --registry=https://registry.npmjs.org/
- 用你当前 taobao 镜像装:npm i -g @toby1123yjh/test-cli@latest --registry=https://registry.npm.taobao.org/系统要求
- Node.js >= 18
- 前端 UI 测试需要 Playwright(建议
npm i -D playwright && npx playwright install) - Git 可选
.test-cli/ 目录结构
.test-cli/
├── config.yaml
├── cases/
│ └── <module>/
│ ├── case.yaml
│ └── script/
│ ├── test.spec.ts # frontend (Playwright)
│ └── test.api.mjs # backend (Node + fetch)
└── tests/
└── <timestamp>/
├── report.md
├── report.html
└── artifacts/快速开始
- 启动交互式 CLI:
test-cli- 生成并加载配置(会创建
.test-cli/config.yaml、.test-cli/cases/、.test-cli/tests/):
/config- 编辑
.test-cli/config.yaml(示例):
project:
name: "my-app"
baseUrl: "http://localhost:3000"
provider:
# openai | anthropic | gemini | deepseek
provider: "openai"
model: "gpt-4o-mini"
# apiKey: ${OPENAI_API_KEY}- 生成测试:
- 前端:
/generate login https://example.com/login- 后端(需要
project.baseUrl或在提示里包含 URL):
/generate api- 运行测试(模块可选;不传则跑所有可运行模块):
/run
/run login报告输出在 .test-cli/tests/<timestamp>/{report.md, report.html}。
Slash Commands
| 命令 | 说明 |
|------|------|
| /help | 显示命令列表 |
| /clear | 清屏 |
| /config | 创建/重载 .test-cli/config.yaml 并准备目录 |
| /generate <module> [url] [notes...] | 生成 case.yaml + 可运行脚本 |
| /update <module> [notes...] | 更新 case.yaml 并重新生成脚本 |
| /validate [file] [--dir <dir>] | 校验 case.yaml(主要用于 frontend case) |
| /run [module] [--mode frontend|backend] [--filter ...] [--timeout ...] | 执行脚本并生成报告 |
| /new | 已废弃(请使用 /generate) |
CLI(非交互)
# 与 /run 等价
test-cli run [module] [--mode frontend|backend] [--filter "..."]
# CI 模式:执行 YAML 测试用例(不依赖生成脚本)
test-cli run --ci [--filter "..."]开发
pnpm install
pnpm test
pnpm typecheck
pnpm build许可证
MIT
