playwright-sniff
Version:
Monitoring library for Playwright that measures action times, catches showstoppers and generates reports
87 lines (86 loc) • 2.26 kB
TypeScript
import { ShowStopper, SniffConfig, SniffOptions, TestReport } from './types';
declare module '@playwright/test' {
interface PlaywrightWorkerOptions {
sniffOptions?: SniffOptions;
}
}
/**
* PlaywrightSniff - A monitoring tool for Playwright actions
*/
export declare class PlaywrightSniff {
private page;
private options;
private failures;
private showStoppers;
private requestStartTimes;
private requestDurations;
private detailedRequestDurations;
private timings;
private isMonitoring;
private testName;
private reportData;
private logger;
/**
* Default options for monitoring
*/
static readonly DEFAULT_OPTIONS: Required<SniffOptions>;
/**
* Creates a new PlaywrightSniff instance
*/
constructor(config: SniffConfig);
/**
* Start monitoring page actions
*/
start(): Promise<void>;
/**
* Stop monitoring page actions
*/
stop(): void;
/**
* Measure the execution time of an action
* @param action Function to execute and measure
* @param label Label to identify the action
*/
measureAction(action: () => Promise<void>, label: string): Promise<void>;
/**
* Add a custom failure
*/
addFailure(error: string, type?: 'console' | 'request' | 'custom', metadata?: Record<string, any>): void;
/**
* Add a custom showstopper
*/
addShowStopper(label: string, criticalError: string): Promise<void>;
/**
* Get the current sniffing results
*/
getResults(): TestReport;
/**
* Generate and save a report
*/
saveReport(outputFile?: string): string;
/**
* Generate HTML Report
*/
generateHTMLReport(outputHTML?: string): void;
/**
* Check if there are any showstoppers
*/
hasShowStoppers(): boolean;
/**
* Get list of showstoppers
*/
getShowStoppers(): ShowStopper[];
setTestName(name: string): void;
/**
* Setup all listeners for sniffing
*/
private setupSniffingListeners;
/**
* Setup handler for alerts on the page
*/
private setupAlertHandler;
/**
* Capture a screenshot for an error
*/
private captureErrorScreenshot;
}