@@ -123,6 +123,10 @@ function createFakeProcess() {
|
123 | 123 | }) as unknown as NodeJS.Process; |
124 | 124 | } |
125 | 125 | |
| 126 | +function firstMockCall<T extends unknown[]>(mock: { mock: { calls: T[] } }): T | undefined { |
| 127 | +return mock.mock.calls[0]; |
| 128 | +} |
| 129 | + |
126 | 130 | async function writeRuntimePostBuildScaffold(tmp: string): Promise<void> { |
127 | 131 | const pluginSdkAliasPath = path.join(tmp, "src", "plugin-sdk", "root-alias.cjs"); |
128 | 132 | await fs.mkdir(path.dirname(pluginSdkAliasPath), { recursive: true }); |
@@ -847,7 +851,7 @@ describe("run-node script", () => {
|
847 | 851 | |
848 | 852 | expect(exitCode).toBe(0); |
849 | 853 | expect(runRuntimePostBuild).toHaveBeenCalledTimes(1); |
850 | | -const postBuildParams = runRuntimePostBuild.mock.calls.at(0)?.[0] as |
| 854 | +const postBuildParams = firstMockCall(runRuntimePostBuild)?.[0] as |
851 | 855 | | { cwd?: string; env?: Record<string, string | undefined> } |
852 | 856 | | undefined; |
853 | 857 | expect(postBuildParams?.cwd).toBe(tmp); |
@@ -1328,9 +1332,7 @@ describe("run-node script", () => {
|
1328 | 1332 | |
1329 | 1333 | expect(exitCode).toBe(143); |
1330 | 1334 | expect(spawn).toHaveBeenCalledTimes(1); |
1331 | | -const spawnCall = spawn.mock.calls.at(0) as |
1332 | | -| [string, string[], { stdio?: unknown }] |
1333 | | -| undefined; |
| 1335 | +const spawnCall = firstMockCall(spawn) as [string, string[], { stdio?: unknown }] | undefined; |
1334 | 1336 | expect(spawnCall?.[0]).toBe(process.execPath); |
1335 | 1337 | expect(spawnCall?.[1]).toEqual(["openclaw.mjs", "status"]); |
1336 | 1338 | expect(spawnCall?.[2].stdio).toBe("inherit"); |
|