Extend E2E assertions

This commit is contained in:
Andras Schmelczer 2026-03-28 11:46:06 +00:00
commit e8c57b3a37
2 changed files with 532 additions and 239 deletions

View file

@ -0,0 +1,25 @@
export class TestErrorTracker {
private firstError: { agentName: string; message: string } | null = null;
public recordError(agentName: string, message: string): void {
this.firstError ??= { agentName, message };
}
/**
* If an error was recorded, throw it. Call this at natural checkpoints:
* after each iteration, before assertions, etc.
*/
public checkAndThrow(): void {
if (this.firstError !== null) {
const { agentName, message } = this.firstError;
throw new Error(
`ERROR-level log from ${agentName}: ${message}`
);
}
}
/** Clear recorded errors. Call at the start of each test. */
public reset(): void {
this.firstError = null;
}
}

View file

@ -1,3 +1,10 @@
export class TimeoutError extends Error {
public constructor(message: string) {
super(message);
this.name = "TimeoutError";
}
}
export async function withTimeout<T>(
promise: Promise<T>,
timeoutMs: number,
@ -8,7 +15,9 @@ export async function withTimeout<T>(
new Promise<T>((_, reject) =>
setTimeout(() => {
reject(
new Error(`${operationName} timed out after ${timeoutMs}ms`)
new TimeoutError(
`${operationName} timed out after ${timeoutMs}ms`
)
);
}, timeoutMs)
)