Files
openclaw/docs/zh-CN/reference/test.md
Seb Slight 929a3725d3 docs: canonicalize docs paths and align zh navigation (#11428)
* docs(navigation): canonicalize paths and align zh nav

* chore(docs): remove stray .DS_Store

* docs(scripts): add non-mint docs link audit

* docs(nav): fix zh source paths and preserve legacy redirects (#11428) (thanks @sebslight)

* chore(docs): satisfy lint for docs link audit script (#11428) (thanks @sebslight)
2026-02-07 15:40:35 -05:00

58 lines
2.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
read_when:
- 运行或修复测试
summary: 如何在本地运行测试vitest以及何时使用 force/coverage 模式
title: 测试
x-i18n:
generated_at: "2026-02-03T10:09:52Z"
model: claude-opus-4-5
provider: pi
source_hash: be7b751fb81c8c94b1293624bdca6582e60a26084960d1df9558061969502e6f
source_path: reference/test.md
workflow: 15
---
# 测试
- 完整测试套件测试集、实时测试、Docker[测试](/help/testing)
- `pnpm test:force`:终止任何占用默认控制端口的遗留 Gateway 网关进程,然后使用隔离的 Gateway 网关端口运行完整的 Vitest 套件,这样服务器测试不会与正在运行的实例冲突。当之前的 Gateway 网关运行占用了端口 18789 时使用此命令。
- `pnpm test:coverage`:使用 V8 覆盖率运行 Vitest。全局阈值为 70% 的行/分支/函数/语句覆盖率。覆盖率排除了集成密集型入口点CLI 连接、gateway/telegram 桥接、webchat 静态服务器),以保持目标集中在可单元测试的逻辑上。
- `pnpm test:e2e`:运行 Gateway 网关端到端冒烟测试(多实例 WS/HTTP/节点配对)。
- `pnpm test:live`运行提供商实时测试minimax/zai。需要 API 密钥和 `LIVE=1`(或提供商特定的 `*_LIVE_TEST=1`)才能取消跳过。
## 模型延迟基准测试(本地密钥)
脚本:[`scripts/bench-model.ts`](https://github.com/openclaw/openclaw/blob/main/scripts/bench-model.ts)
用法:
- `source ~/.profile && pnpm tsx scripts/bench-model.ts --runs 10`
- 可选环境变量:`MINIMAX_API_KEY``MINIMAX_BASE_URL``MINIMAX_MODEL``ANTHROPIC_API_KEY`
- 默认提示词:"Reply with a single word: ok. No punctuation or extra text."
上次运行2025-12-3120 次):
- minimax 中位数 1279ms最小 1114最大 2431
- opus 中位数 2454ms最小 1224最大 3170
## 新手引导 E2EDocker
Docker 是可选的;这仅用于容器化的新手引导冒烟测试。
在干净的 Linux 容器中完整的冷启动流程:
```bash
scripts/e2e/onboard-docker.sh
```
此脚本通过伪终端驱动交互式向导,验证配置/工作区/会话文件,然后启动 Gateway 网关并运行 `openclaw health`
## QR 导入冒烟测试Docker
确保 `qrcode-terminal` 在 Docker 中的 Node 22+ 下加载:
```bash
pnpm test:docker:qr
```