fix(cron): improve test helper error reporting for lastEmbeddedCall

Replace embedded expect assertion with an explicit throw so failures
report at the call-site rather than inside the helper, making it
easier to identify which test case triggered the problem.
This commit is contained in:
Jerry-Xin 2026-03-16 16:09:23 +08:00
parent 40e262874a
commit b7c09cba44

View File

@ -28,8 +28,9 @@ const withTempHome = withTempCronHome;
*/
function lastEmbeddedCall(): { provider?: string; model?: string } {
const calls = vi.mocked(runEmbeddedPiAgent).mock.calls;
expect(calls.length).toBeGreaterThan(0);
return calls.at(-1)?.[0] as { provider?: string; model?: string };
const last = calls.at(-1)?.[0] as { provider?: string; model?: string } | undefined;
if (!last) throw new Error("runEmbeddedPiAgent was never called");
return last;
}
async function runCronWithModel(