diff --git a/src/gateway/server-cron.test.ts b/src/gateway/server-cron.test.ts index a32862be306a..841b8e3648f1 100644 --- a/src/gateway/server-cron.test.ts +++ b/src/gateway/server-cron.test.ts @@ -126,8 +126,13 @@ function callArg( label: string, ) { const call = mock.mock.calls.at(callIndex); - expect(call, label).toBeDefined(); - return call?.[argIndex]; + if (!call) { + throw new Error(`Expected mock call: ${label}`); + } + if (argIndex >= call.length) { + throw new Error(`Expected mock call argument ${argIndex}: ${label}`); + } + return call[argIndex]; } function expectHookContext(callIndex: number, fields: { config?: unknown; hasGetCron?: boolean }) {