@@ -323,8 +323,12 @@ function requireRecord(value: unknown, label: string): Record<string, unknown> {
|
323 | 323 | return value as Record<string, unknown>; |
324 | 324 | } |
325 | 325 | |
| 326 | +function firstMockCall(mock: { mock: { calls: unknown[][] } }): unknown[] | undefined { |
| 327 | +return mock.mock.calls[0]; |
| 328 | +} |
| 329 | + |
326 | 330 | function requireHookPayload(handler: ReturnType<typeof vi.fn>): Record<string, unknown> { |
327 | | -const payload = handler.mock.calls.at(0)?.[0]; |
| 331 | +const payload = firstMockCall(handler)?.[0]; |
328 | 332 | return requireRecord(payload, "before_install hook payload"); |
329 | 333 | } |
330 | 334 | |
@@ -664,7 +668,9 @@ describe("installPluginFromArchive", () => {
|
664 | 668 | }); |
665 | 669 | |
666 | 670 | expect(result.ok).toBe(true); |
667 | | -const commandRun = vi.mocked(runCommandWithTimeout).mock.calls.at(0); |
| 671 | +const commandRun = firstMockCall(vi.mocked(runCommandWithTimeout)) as |
| 672 | +| Parameters<typeof runCommandWithTimeout> |
| 673 | +| undefined; |
668 | 674 | expect(commandRun?.[0]).toContain("npm"); |
669 | 675 | expect(commandRun?.[0]).toContain("install"); |
670 | 676 | const commandOptions = commandRun?.[1]; |
@@ -2412,7 +2418,7 @@ describe("installPluginFromArchive", () => {
|
2412 | 2418 | version: "1.0.0", |
2413 | 2419 | extensions: ["index.js"], |
2414 | 2420 | }); |
2415 | | -expect(handler.mock.calls.at(0)?.[1]).toEqual({ |
| 2421 | +expect(firstMockCall(handler)?.[1]).toEqual({ |
2416 | 2422 | origin: "plugin-package", |
2417 | 2423 | targetType: "plugin", |
2418 | 2424 | requestKind: "plugin-dir", |
|