Kiểm thử
- Bộ công cụ kiểm thử đầy đủ (suite, live, Docker): Testing
-
pnpm test:force: Kills any lingering gateway process holding the default control port, then runs the full Vitest suite with an isolated gateway port so server tests don’t collide with a running instance. Use this when a prior gateway run left port 18789 occupied. -
pnpm test:coverage: Chạy bộ kiểm thử unit với V8 coverage (thông quavitest.unit.config.ts). 4. Ngưỡng toàn cục là 70% cho lines/branches/functions/statements. Coverage excludes integration-heavy entrypoints (CLI wiring, gateway/telegram bridges, webchat static server) to keep the target focused on unit-testable logic. -
pnpm testtrên Node 24+: OpenClaw tự động tắt VitestvmForksvà sử dụngforksđể tránh lỗiERR_VM_MODULE_LINK_FAILURE/module is already linked. Bạn có thể ép buộc hành vi bằngOPENCLAW_TEST_VM_FORKS=0|1. -
pnpm test:e2e: Chạy các smoke test end-to-end của gateway (ghép cặp WS/HTTP/node đa instance). Mặc định dùngvmForks+ worker thích ứng trongvitest.e2e.config.ts; điều chỉnh bằngOPENCLAW_E2E_WORKERS=<n>và đặtOPENCLAW_E2E_VERBOSE=1để bật log chi tiết. -
pnpm test:live: Chạy các bài kiểm thử live của provider (minimax/zai). Requires API keys andLIVE=1(or provider-specific*_LIVE_TEST=1) to unskip.
Benchmark độ trễ mô hình (khóa cục bộ)
Script:scripts/bench-model.ts
Cách dùng:
source ~/.profile && pnpm tsx scripts/bench-model.ts --runs 10- Biến môi trường tùy chọn:
MINIMAX_API_KEY,MINIMAX_BASE_URL,MINIMAX_MODEL,ANTHROPIC_API_KEY - Default prompt: “Reply with a single word: ok. No punctuation or extra text.”
- minimax median 1279ms (min 1114, max 2431)
- opus median 2454ms (min 1224, max 3170)
Onboarding E2E (Docker)
Docker là tùy chọn; chỉ cần cho các smoke test onboarding chạy trong container. Luồng khởi động nguội đầy đủ trong một container Linux sạch:openclaw health.
Smoke test nhập QR (Docker)
Đảm bảoqrcode-terminal tải được dưới Node 22+ trong Docker: