























@@ -4,7 +4,13 @@ import { describe, expect, it } from "vitest";
44import { createOpenClawTestState, withOpenClawTestState } from "./openclaw-test-state.js";
5566async function expectPathMissing(targetPath: string): Promise<void> {
7-await expect(fs.stat(targetPath)).rejects.toMatchObject({ code: "ENOENT" });
7+try {
8+await fs.stat(targetPath);
9+} catch (error) {
10+expect((error as NodeJS.ErrnoException).code).toBe("ENOENT");
11+return;
12+}
13+throw new Error(`expected missing path: ${targetPath}`);
814}
9151016describe("openclaw test state", () => {
@@ -153,14 +159,12 @@ describe("openclaw test state", () => {
153159});
154160155161expect(profilePath).toBe(path.join(state.agentDir(), "auth-profiles.json"));
156-expect(JSON.parse(await fs.readFile(profilePath, "utf8"))).toMatchObject({
157-version: 1,
158-profiles: {
159-"openai:test": {
160-provider: "openai",
161-},
162-},
163-});
162+const profiles = JSON.parse(await fs.readFile(profilePath, "utf8")) as {
163+version?: unknown;
164+profiles?: Record<string, { provider?: unknown }>;
165+};
166+expect(profiles.version).toBe(1);
167+expect(profiles.profiles?.["openai:test"]?.provider).toBe("openai");
164168},
165169);
166170});
@@ -172,15 +176,9 @@ describe("openclaw test state", () => {
172176},
173177async (state) => {
174178const config = JSON.parse(await fs.readFile(state.configPath, "utf8"));
175-expect(config).toMatchObject({
176-update: {
177-channel: "stable",
178-},
179-plugins: {
180-enabled: true,
181-allow: ["discord", "telegram", "whatsapp", "memory"],
182-},
183-});
179+expect(config.update?.channel).toBe("stable");
180+expect(config.plugins?.enabled).toBe(true);
181+expect(config.plugins?.allow).toStrictEqual(["discord", "telegram", "whatsapp", "memory"]);
184182},
185183);
186184});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。