tests cleanup

This commit is contained in:
2026-01-03 18:46:36 +01:00
parent 540c0fcb7a
commit c589b3c3fe
17 changed files with 402 additions and 2812 deletions

View File

@@ -0,0 +1,55 @@
import { Page } from '@playwright/test';
export interface CapturedError {
type: 'console' | 'page';
message: string;
stack?: string;
timestamp: number;
}
export class ConsoleErrorCapture {
private errors: CapturedError[] = [];
constructor(private page: Page) {
this.setupCapture();
}
private setupCapture(): void {
this.page.on('console', (msg) => {
if (msg.type() === 'error') {
this.errors.push({
type: 'console',
message: msg.text(),
timestamp: Date.now(),
});
}
});
this.page.on('pageerror', (error) => {
this.errors.push({
type: 'page',
message: error.message,
stack: error.stack ?? '',
timestamp: Date.now(),
});
});
}
public getErrors(): CapturedError[] {
return this.errors;
}
public hasErrors(): boolean {
return this.errors.length > 0;
}
public clear(): void {
this.errors = [];
}
public async waitForErrors(timeout: number = 1000): Promise<boolean> {
await this.page.waitForTimeout(timeout);
return this.hasErrors();
}
}