@mottyjs /测试
Motty SDK的测试套件,与作者自己的测试运行器一起使用。 fake 和 on 脚本的
模型, memory 存储是用于测试的吗 run 请求的整个生命周期是否没有
电线。箱子、桌子和覆盖物都要留给跑步者。
bun add --dev @mottyjs/test
import { fake, memory, on, run } from "@mottyjs/test";
由脚本化模型回答的请求:
import { expect, test } from "bun:test";
import { model, motty } from "@mottyjs/core";
import { fake, on, run } from "@mottyjs/test";
const luna = model("openai/gpt-6-luna");
const relay = motty({ name: "relay" }).handle(({ prompt }) => luna.complete(prompt));
test("a question is answered by the small model", async () => {
const models = fake(on(luna, "quick reply"));
const { answer } = await run(
relay,
{ text: "What does git stash do?" },
{ models: [models] },
);
expect(await answer.text()).toBe("quick reply");
});
false将连接的规则应用于调用可能声明的头。默认情况下不转发,
和需要 forwardHeaders 就像适配器一样,在它的脚本之前。它不包含其
因此,真实连接的名称或其API状态不会被假连接遗漏。什么 sent 返回
只保留规则允许通过的头,其余的是调用的警告:
const models = fake({ forwardHeaders: ["x-session"] }, on(luna, "quick reply"));
SDK作为一个整体在 根的自述,以及其设计背后的原因 ARCHITECTURE.md.