Skip to content

Commit b4fdb90

Browse files
committed
🤖 fix: throw on sendMessageAndWait timeout instead of silently returning partial events
The helper was ignoring the return value of waitForEvent, so when a timeout occurred tests would get partial events without stream-end, causing confusing assertion failures like 'expected undefined to be defined'. Now throws a clear error with diagnostics: 'Timeout waiting for stream-end after Xms'
1 parent 6830b71 commit b4fdb90

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

‎tests/ipcMain/helpers.ts‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,16 @@ export async function sendMessageAndWait(
232232

233233
// Wait for stream completion
234234
const collector = createEventCollector(env.sentEvents, workspaceId);
235-
await collector.waitForEvent("stream-end", timeoutMs);
235+
const streamEnd = await collector.waitForEvent("stream-end", timeoutMs);
236+
237+
if (!streamEnd) {
238+
collector.logEventDiagnostics(`sendMessageAndWait timeout after ${timeoutMs}ms`);
239+
throw new Error(
240+
`sendMessageAndWait: Timeout waiting for stream-end after ${timeoutMs}ms.\n` +
241+
`See detailed event diagnostics above.`
242+
);
243+
}
244+
236245
return collector.getEvents();
237246
}
238247

0 commit comments

Comments
 (0)