




















@@ -171,7 +171,13 @@ function resolvePath(tmp: string, relativePath: string) {
171171}
172172173173async function expectPathMissing(targetPath: string): Promise<void> {
174-await expect(fs.access(targetPath)).rejects.toMatchObject({ code: "ENOENT" });
174+let accessError: unknown;
175+try {
176+await fs.access(targetPath);
177+} catch (error) {
178+accessError = error;
179+}
180+expect((accessError as NodeJS.ErrnoException | undefined)?.code).toBe("ENOENT");
175181}
176182177183async function writeProjectFiles(tmp: string, files: Record<string, string>) {
@@ -346,9 +352,10 @@ async function runQaCommand(params: {
346352}
347353348354async function expectManifestId(tmp: string, relativePath: string, id: string) {
349-await expect(
350-fs.readFile(resolvePath(tmp, relativePath), "utf-8").then((raw) => JSON.parse(raw)),
351-).resolves.toMatchObject({ id });
355+const manifest = JSON.parse(await fs.readFile(resolvePath(tmp, relativePath), "utf-8")) as {
356+id?: unknown;
357+};
358+expect(manifest.id).toBe(id);
352359}
353360354361describe("run-node script", () => {
@@ -444,11 +451,7 @@ describe("run-node script", () => {
444451await expect(
445452fs.readFile(resolvePath(tmp, "dist/plugin-sdk/root-alias.cjs"), "utf-8"),
446453).resolves.toContain("module.exports = {};");
447-await expect(
448-fs
449-.readFile(resolvePath(tmp, DIST_EXTENSION_MANIFEST), "utf-8")
450-.then((raw) => JSON.parse(raw)),
451-).resolves.toMatchObject({ id: "demo" });
454+await expectManifestId(tmp, DIST_EXTENSION_MANIFEST, "demo");
452455await expect(
453456fs.readFile(resolvePath(tmp, DIST_EXTENSION_PACKAGE), "utf-8"),
454457).resolves.toContain(
@@ -843,15 +846,13 @@ describe("run-node script", () => {
843846const exitCode = await runQaCommand({ tmp, spawn, spawnSync, runRuntimePostBuild });
844847845848expect(exitCode).toBe(0);
846-expect(runRuntimePostBuild).toHaveBeenCalledWith(
847-expect.objectContaining({
848-cwd: tmp,
849-env: expect.objectContaining({
850-OPENCLAW_BUILD_PRIVATE_QA: "1",
851-OPENCLAW_ENABLE_PRIVATE_QA_CLI: "1",
852-}),
853-}),
854-);
849+expect(runRuntimePostBuild).toHaveBeenCalledTimes(1);
850+const postBuildParams = runRuntimePostBuild.mock.calls[0]?.[0] as
851+| { cwd?: string; env?: Record<string, string | undefined> }
852+| undefined;
853+expect(postBuildParams?.cwd).toBe(tmp);
854+expect(postBuildParams?.env?.OPENCLAW_BUILD_PRIVATE_QA).toBe("1");
855+expect(postBuildParams?.env?.OPENCLAW_ENABLE_PRIVATE_QA_CLI).toBe("1");
855856});
856857});
857858@@ -1326,11 +1327,11 @@ describe("run-node script", () => {
13261327const exitCode = await exitCodePromise;
1327132813281329expect(exitCode).toBe(143);
1329-expect(spawn).toHaveBeenCalledWith(
1330- process.execPath,
1331- ["openclaw.mjs", "status"],
1332- expect.objectContaining({ stdio: "inherit" }),
1333-);
1330+expect(spawn).toHaveBeenCalledTimes(1);
1331+const spawnCall = spawn.mock.calls[0] as [string, string[], { stdio?: unknown }] | undefined;
1332+expect(spawnCall?.[0]).toBe(process.execPath);
1333+expect(spawnCall?.[1]).toEqual(["openclaw.mjs", "status"]);
1334+expect(spawnCall?.[2].stdio).toBe("inherit");
13341335expect(child.kill).toHaveBeenCalledWith("SIGTERM");
13351336expect(fakeProcess.listenerCount("SIGINT")).toBe(0);
13361337expect(fakeProcess.listenerCount("SIGTERM")).toBe(0);
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。