




























@@ -44,6 +44,15 @@ type CapturedBackupManifest = {
4444describe("backup commands", () => {
4545let tempHome: TempHomeEnv;
464647+function requireFirstMockArg<T>(mock: { mock: { calls: T[][] } }, label: string): T {
48+const call = mock.mock.calls.at(0);
49+if (!call) {
50+throw new Error(`expected ${label} call`);
51+}
52+const [arg] = call;
53+return arg;
54+}
55+4756async function mockWorkspaceBackupPlan(stateDir: string, workspaceDir: string, nowMs: number) {
4857vi.spyOn(backupShared, "resolveBackupPlanFromDisk").mockResolvedValue(
4958await resolveBackupPlanFromPaths({
@@ -368,7 +377,7 @@ describe("backup commands", () => {
368377369378expect(result.skippedVolatileCount).toBe(1);
370379expect(runtime.log).toHaveBeenCalledTimes(1);
371-const payload = vi.mocked(runtime.log).mock.calls[0]?.[0];
380+const payload = requireFirstMockArg(vi.mocked(runtime.log), "runtime log");
372381if (typeof payload !== "string") {
373382throw new Error("backup test expected JSON string output");
374383}
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。