diff --git a/src/commands/doctor.runs-legacy-state-migrations-yes-mode-without.e2e.test.ts b/src/commands/doctor.runs-legacy-state-migrations-yes-mode-without.e2e.test.ts index 6ea4658bf4f..5a896425fd1 100644 --- a/src/commands/doctor.runs-legacy-state-migrations-yes-mode-without.e2e.test.ts +++ b/src/commands/doctor.runs-legacy-state-migrations-yes-mode-without.e2e.test.ts @@ -126,7 +126,15 @@ describe("doctor command", () => { } } - const written = writeConfigFile.mock.calls.at(-1)?.[0] as Record; + const written = writeConfigFile.mock.calls + .map((call) => call[0] as Record) + .find((candidate) => { + const auth = candidate.auth as { profiles?: unknown } | undefined; + return Boolean(auth?.profiles); + }); + if (!written) { + throw new Error("Expected doctor to write migrated auth profiles"); + } const profiles = (written.auth as { profiles: Record }).profiles; expect(profiles["anthropic:me@example.com"]).toBeTruthy(); expect(profiles["anthropic:default"]).toBeUndefined();