test: fail fast on google prompt cache calls

This commit is contained in:
Peter Steinberger
2026-05-11 18:48:16 +01:00
parent ee0760172d
commit bf8bcae8b2

View File

@@ -81,9 +81,14 @@ function createCapturingStreamFn(result = "stream") {
}
function callArg(mock: { mock: { calls: unknown[][] } }, callIndex: number, argIndex: number) {
const call = mock.mock.calls[callIndex];
expect(call).toBeDefined();
return call?.[argIndex];
const call = mock.mock.calls.at(callIndex);
if (!call) {
throw new Error(`Expected mock call ${callIndex}`);
}
if (argIndex >= call.length) {
throw new Error(`Expected mock call ${callIndex} argument ${argIndex}`);
}
return call[argIndex];
}
function fetchInit(fetchMock: { mock: { calls: unknown[][] } }, callIndex = 0): RequestInit {