SuperAPI AI 工具集

testing-flow

测试与质量

查看项目

更新于 10-16 00:20

技能介绍

用途:为 Robomotion 流程运行和编写行为测试,测试文件为 *.test.ts,使用 bun test 执行,依赖 @robomotion/sdk/testing。适合需要验证流程结构、Mock 服务、检查 Function 节点逻辑或在集成模式下跑真实服务的场景。

主要能力:FlowTester 加载并检查流程、运行检查点、分析路径与复杂度;MockRegistry 按节点或按类型 Mock 外部服务并追踪调用;extractFunc、runFunc 等用于隔离测试 Function 节点的 JavaScript;SubflowTester 可单独运行子流程;isIntegrationMode、hasCredentials 通过环境变量区分单元与真实服务模式。

使用方式:在 main.ts 旁创建 main.test.ts,使用 bun test 运行。先检查流程目录下是否已有 *.test.ts,有则进入目录运行 bun test,失败后诊断修改并重跑。测试结构可用 tester.validate()、getNodes()、allBranchesTerminate()、findLoops()、analyzeFlow() 等断言。Mock 通过 MockRegistry.registerNode 或 register 注册,afterEach 与 afterAll 中分别 resetCalls 和 clear 避免污染。设 INTEGRATION=1 bun test 可切换到真实服务。

限制:该技能聚焦行为测试,pspec schema 校验需使用 validating-flow。集成测试需要相应凭据,否则跳过。测试文件命名与 bun 运行环境为必需条件。