



























@@ -1,3 +1,4 @@
1+import type { SpawnOptions } from "node:child_process";
12import { EventEmitter } from "node:events";
23import { PassThrough } from "node:stream";
34import { afterEach, describe, expect, it, vi } from "vitest";
@@ -45,11 +46,7 @@ describe("OpenClawStdioClientTransport", () => {
4546child.emit("spawn");
4647await started;
474848-const [command, args, options] = spawnMock.mock.calls[0] as [
49-string,
50-string[],
51-{ env?: NodeJS.ProcessEnv },
52-];
49+const [command, args, options] = spawnMock.mock.calls[0] as [string, string[], SpawnOptions];
5350if (process.platform === "linux") {
5451expect(command).toBe("/bin/sh");
5552expect(args).toEqual([
@@ -63,15 +60,11 @@ describe("OpenClawStdioClientTransport", () => {
6360expect(command).toBe("npx");
6461expect(args).toEqual(["-y", "example-mcp"]);
6562}
66-expect(options).toEqual(
67-expect.objectContaining({
68-cwd: "/tmp/example",
69-detached: process.platform !== "win32",
70-shell: false,
71-stdio: ["pipe", "pipe", "pipe"],
72-}),
73-);
74-expect(options.env).toEqual(expect.objectContaining({ EXAMPLE: "1" }));
63+expect(options.cwd).toBe("/tmp/example");
64+expect(options.detached).toBe(process.platform !== "win32");
65+expect(options.shell).toBe(false);
66+expect(options.stdio).toEqual(["pipe", "pipe", "pipe"]);
67+expect(options.env?.EXAMPLE).toBe("1");
7568expect(transport.pid).toBe(4321);
7669expect(transport.stderr).toBeInstanceOf(PassThrough);
7770});
@@ -159,9 +152,9 @@ describe("OpenClawStdioClientTransport", () => {
159152child.emit("spawn");
160153await started;
161154162-await expect(
163-transport.send({ jsonrpc: "2.0", id: 2, method: "ping" }),
164-).rejects.toThrow("EPIPE");
155+await expect(transport.send({ jsonrpc: "2.0", id: 2, method: "ping" })).rejects.toThrow(
156+"EPIPE",
157+);
165158});
166159167160it("rejects send() when stdin.write throws synchronously (#75438)", async () => {
@@ -179,8 +172,8 @@ describe("OpenClawStdioClientTransport", () => {
179172child.emit("spawn");
180173await started;
181174182-await expect(
183-transport.send({ jsonrpc: "2.0", id: 3, method: "ping" }),
184-).rejects.toThrow("write after end");
175+await expect(transport.send({ jsonrpc: "2.0", id: 3, method: "ping" })).rejects.toThrow(
176+"write after end",
177+);
185178});
186179});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。