Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Webdriverio Webdriverio MSPO Aggregator

From Leeroopedia
Knowledge Sources
Domains Mobile_Testing, Performance_Optimization
Last Updated 2026-02-12 00:00 GMT

Overview

The MSPO Aggregator module collects selector performance data from all worker processes and generates consolidated CLI and markdown reports.

Description

This module provides the aggregateSelectorPerformanceData function which reads per-worker JSON data files, merges them, groups entries by device name, and produces structured output. It generates JSON reports unconditionally, and optionally produces CLI terminal output and markdown reports based on configuration flags. The getDeviceName helper extracts device identifiers from various capability structures (standard, multiremote, and W3C).

Usage

This module is called by AppiumLauncher.onComplete() at the end of a test run to aggregate performance data collected by individual worker processes. It should not typically be called directly by end users.

Code Reference

Source Location

Signature

export async function aggregateSelectorPerformanceData(
    capabilities: Capabilities.TestrunnerCapabilities | Capabilities.ResolvedTestrunnerCapabilities,
    maxLineLength: number,
    writeFn?: (message: string) => void,
    reportDirectory?: string,
    options?: ReportOptions
): Promise<void>

export function getDeviceName(
    capabilities: Capabilities.TestrunnerCapabilities | Capabilities.ResolvedTestrunnerCapabilities
): string

Import

import { aggregateSelectorPerformanceData, getDeviceName } from './mobileSelectorPerformanceOptimizer/aggregator.js'

I/O Contract

Inputs

Name Type Required Description
capabilities Capabilities.ResolvedTestrunnerCapabilities Yes Capabilities used to extract device name as a fallback
maxLineLength number Yes Maximum line length for CLI report line wrapping
writeFn (message: string) => void No Custom write function for output; defaults to process.stdout.write
reportDirectory string No Directory path where JSON and markdown reports are written
options ReportOptions No Flags controlling enableCliReport and enableMarkdownReport output

Outputs

Name Type Description
aggregateSelectorPerformanceData return Promise<void> Resolves when all reports have been written; throws SevereServiceError if reportDirectory is missing
getDeviceName return string Device name extracted from capabilities, or 'unknown' if not found

Usage Examples

Aggregating Data in onComplete

import { aggregateSelectorPerformanceData } from './mobileSelectorPerformanceOptimizer/aggregator.js'

async onComplete(exitCode: number, config: Options.Testrunner, capabilities: Capabilities.TestrunnerCapabilities) {
    await aggregateSelectorPerformanceData(
        capabilities,
        100,                // maxLineLength
        undefined,          // default writeFn
        './reports',        // reportDirectory
        { enableCliReport: true, enableMarkdownReport: true }
    )
}

Extracting Device Name

import { getDeviceName } from './mobileSelectorPerformanceOptimizer/aggregator.js'

const deviceName = getDeviceName(capabilities)
// e.g., "iPhone 15 Pro" or "unknown"

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment