UNPKG

playwright-performance-reporter

Version:

Measure and publish performance metrics from browser dev-tools when running playwright

89 lines (88 loc) 2.73 kB
import { type FullConfig, type FullResult, type Reporter, type Suite, type TestCase, type TestResult, type TestStep } from '@playwright/test/reporter'; import { type Options } from '../types/index.js'; export declare class PerformanceReporter implements Reporter { private readonly options; /** * Maps unique playwright test ids to the computed name */ private readonly idToNameMapping; private readonly metricsEngine; /** * Writers to stream data to different outputs */ private readonly presenters; /** * Latest test step identifier */ private latestStepId; /** * Latest case identifier */ private latestCaseId; /** * Latest test name */ private latestName; /** * Reference to the unsubscribe function for a hook and test id */ private readonly samplingRunner; constructor(options: Options); onBegin(config: FullConfig, suite: Suite): void; onEnd(result: FullResult): Promise<void>; onTestBegin(test: TestCase, result: TestResult): Promise<void>; onTestEnd(test: TestCase, result: TestResult): Promise<void>; onStepBegin(test: TestCase, result: TestResult, step: TestStep): Promise<void>; onStepEnd(test: TestCase, result: TestResult, step: TestStep): Promise<void>; /** * Write data to all presenters concurrently * * @param content the content to write */ private writeToPresenters; /** * Close all presenters */ private closePresenters; /** * Delete files from all presenters */ private deleteFromPresenters; /** * Add new `TestPerformance` with identifier * * @param caseId identifier for case * @param stepId identifier for step * @param name human friendly identifier */ private createTestPerformance; /** * Destroys sampling for metrics * * @param caseId identifier for case * @param stepId identifier for step * @param hook playwright hook */ private destroySamplingRunner; /** * Execute metrics gathering for metrics * * @param results result accumulator * @param caseId identifier for case * @param stepId identifier for step * @param hook playwright hook * @param hookOrder playwright hook order * @param browser which settings and metrics to use */ private executeMetrics; /** * Setup sampling for metrics * * @param results result accumulator * @param caseId identifier for case * @param stepId identifier for step * @param hook playwright hook * @param browser which settings and metrics to use */ private executeSamplingMetrics; }