playwright-performance-reporter
Version:
Measure and publish performance metrics from browser dev-tools when running playwright
63 lines (62 loc) • 2.25 kB
TypeScript
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;
/**
* Writer to stream json chunks
*/
private readonly jsonChunkWriter;
/**
* 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): 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>;
/**
* 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 existing metrics and custom 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 existing metrics and custom 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;
}