import WDIOReporter, { type SuiteStats, type RunnerStats, type TestStats } from '@wdio/reporter'; import { type Reporters } from '@wdio/types'; import { type CtrfTest, type CtrfEnvironment, type CtrfReport } from './types/ctrf'; /** * Global key for the runtime function. * Test code uses this to send metadata to the reporter. */ export declare const CTRF_RUNTIME_KEY = "__ctrfTestRuntime"; /** * Runtime message for extra data */ export interface CtrfRuntimeMessage { type: 'extra'; data: Record; } /** * Type for the runtime handler function */ export type CtrfRuntimeHandler = (message: CtrfRuntimeMessage) => void; export interface CtrfReporterConfigOptions extends Partial { minimal?: boolean; testType?: string; appName?: string; appVersion?: string; osPlatform?: string; osRelease?: string; osVersion?: string; buildName?: string; buildNumber?: string; buildUrl?: string; } export default class GenerateCtrfReport extends WDIOReporter { readonly ctrfReport: CtrfReport; private readonly reporterConfigOptions; private readonly outputDir; private currentSuite; private currentSpecFile; private currentBrowser; /** * Runtime metadata collection */ private currentTestTitle; private testMetadata; constructor(options?: CtrfReporterConfigOptions); /** * Register the global runtime handler for test code to send metadata */ private registerRuntimeHandler; /** * Clear the global runtime handler */ private clearRuntimeHandler; /** * Handle runtime messages from test code */ private handleRuntimeMessage; /** * Deep merge two objects following CTRF merge rules: * - Arrays: concatenated * - Objects: recursively merged * - Primitives: overwritten */ private deepMerge; private previousReport?; onSuiteStart(suite: SuiteStats): void; onRunnerStart(runner: RunnerStats): void; onTestStart(test: TestStats): void; onTestEnd(testStats: TestStats): void; private getReportFileName; onRunnerEnd(runner: RunnerStats): void; private updateCtrfTotalsFromTestStats; private updateCtrfTestResultsFromTestStats; hasEnvironmentDetails(environment: CtrfEnvironment): boolean; extractFailureDetails(testResult: TestStats): Partial; private getReportPath; private writeReportToFile; }