






























@@ -86,9 +86,25 @@ function makeFakeProc(overrides: Partial<FakeProc> = {}): FakeProc {
8686return Object.assign(proc, overrides);
8787}
888889-function effectiveSpawnCommand(call: unknown[] | undefined): unknown {
90-const command = call?.[0];
91-const args = call?.[1];
89+function requireSpawnCall(index = 0): unknown[] {
90+const call = spawnMock.mock.calls[index];
91+if (!call) {
92+throw new Error(`expected spawn call #${index + 1}`);
93+}
94+return call;
95+}
96+97+function requireSpawnOptions(index = 0): { env?: NodeJS.ProcessEnv } {
98+const options = requireSpawnCall(index)[2];
99+if (!options || typeof options !== "object") {
100+throw new Error(`expected spawn options for call #${index + 1}`);
101+}
102+return options as { env?: NodeJS.ProcessEnv };
103+}
104+105+function effectiveSpawnCommand(call: unknown[]): unknown {
106+const command = call[0];
107+const args = call[1];
92108if (
93109command === "/bin/sh" &&
94110Array.isArray(args) &&
@@ -454,7 +470,7 @@ describe("chrome.ts internal", () => {
454470const running = await launchOpenClawChrome(makeResolved(), profile);
455471expect(running.pid).toBe(4242);
456472expect(spawnCalls).toBeGreaterThanOrEqual(1);
457-const spawnOptions = spawnMock.mock.calls[0]?.[2] as { env?: NodeJS.ProcessEnv };
473+const spawnOptions = requireSpawnOptions();
458474expect(spawnOptions.env?.HTTP_PROXY).toBeUndefined();
459475expect(spawnOptions.env?.HTTPS_PROXY).toBeUndefined();
460476expect(spawnOptions.env?.NO_PROXY).toBeUndefined();
@@ -491,7 +507,7 @@ describe("chrome.ts internal", () => {
491507executablePath: "/tmp/global-chrome",
492508} as ResolvedBrowserConfig;
493509const running = await launchOpenClawChrome(resolved, profile);
494-expect(effectiveSpawnCommand(spawnMock.mock.calls[0])).toBe("/tmp/profile-chrome");
510+expect(effectiveSpawnCommand(requireSpawnCall())).toBe("/tmp/profile-chrome");
495511running.proc.kill?.("SIGTERM");
496512},
497513});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。