Implementation:Webdriverio Webdriverio MSPO Reporter
| Knowledge Sources | |
|---|---|
| Domains | Mobile_Testing, Reporting |
| Last Updated | 2026-02-12 00:00 GMT |
Overview
MobileSelectorPerformanceReporter is a WDIOReporter extension that tracks test context (file, suite, test name) for correlating selector performance metrics with specific tests.
Description
The MobileSelectorPerformanceReporter extends WDIOReporter and listens to suite and test lifecycle events. It extracts and stores the current test file path, suite name, and test name in a shared store module (mspo-store). This context is consumed by the SelectorPerformanceService to annotate performance data entries with the test that triggered each selector call. The reporter handles nested suite hierarchies, skipping root suites with titles like (root).
Usage
This reporter is automatically registered by SelectorPerformanceService.beforeSession() when selector performance tracking is enabled. It should not be manually added to the reporters array.
Code Reference
Source Location
- Repository: Webdriverio_Webdriverio
- File: packages/wdio-appium-service/src/mobileSelectorPerformanceOptimizer/mspo-reporter.ts
- Lines: 12-147
Signature
export default class MobileSelectorPerformanceReporter extends WDIOReporter {
constructor(options: MobileSelectorPerformanceReporterOptions)
onSuiteStart(suite: SuiteStats): void
onTestStart(test: TestStats): void
onTestPass(_test: TestStats): void
onTestFail(_test: TestStats): void
onTestSkip(test: TestStats): void
onTestPending(test: TestStats): void
onHookStart(): void
onHookEnd(): void
}
Import
import MobileSelectorPerformanceReporter from './mobileSelectorPerformanceOptimizer/mspo-reporter.js'
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| options | MobileSelectorPerformanceReporterOptions |
Yes | Reporter options including optional reportDirectory string |
| suite | SuiteStats |
Yes | Suite statistics containing title and file path, provided by the WDIOReporter framework |
| test | TestStats |
Yes | Test statistics containing title, provided by the WDIOReporter framework |
Outputs
| Name | Type | Description |
|---|---|---|
| Side effects | void |
Sets current test file, suite name, and test name in the shared mspo-store for consumption by the performance service |
Usage Examples
Automatic Registration (Internal)
// The reporter is automatically registered in SelectorPerformanceService.beforeSession():
async beforeSession(config: Options.Testrunner) {
if (this._enabled && config) {
if (!config.reporters) {
config.reporters = []
}
const isAlreadyRegistered = isReporterRegistered(
config.reporters,
'MobileSelectorPerformanceReporter'
)
if (!isAlreadyRegistered) {
const reporterEntry: Reporters.ReporterEntry = [
MobileSelectorPerformanceReporter,
{ reportDirectory: this._reportDirectory }
]
config.reporters.push(reporterEntry)
}
}
}
How Context Flows
// 1. Reporter receives onSuiteStart -> sets current suite name and test file
// 2. Reporter receives onTestStart -> sets current test name
// 3. SelectorPerformanceService.beforeCommand reads context from mspo-store
// 4. Performance data is annotated with { testFile, suiteName, testName }