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 MarkdownFormatter

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

Overview

The MSPO MarkdownFormatter generates structured markdown reports with tables, performance data, and implementation guidance for selector optimization.

Description

The generateMarkdownReport function takes optimized selector data and produces a complete markdown document. The report includes a summary section with impact categorization (high, medium, low, minor), file-based fix tables with clickable source links, workspace-wide optimization suggestions, performance warnings for cases where native selectors were slower, and an implementation guide with selector priority documentation. Internal helpers handle selector deduplication, usage counting, file grouping, path relativization, and markdown table escaping.

Usage

This function is called by the aggregator module when enableMarkdownReport is set to true in the service configuration. The output is written to a .md file in the report directory.

Code Reference

Source Location

Signature

export function generateMarkdownReport(
    optimizedSelectors: SelectorPerformanceData[],
    deviceName: string,
    timingInfo?: RunTimingInfo,
    projectRoot?: string
): string

Import

import { generateMarkdownReport } from './mobileSelectorPerformanceOptimizer/markdown-formatter.js'

I/O Contract

Inputs

Name Type Required Description
optimizedSelectors SelectorPerformanceData[] Yes Array of performance entries that include optimized selector alternatives
deviceName string Yes Device name for the report header (e.g., "iPhone 15 Pro")
timingInfo RunTimingInfo No Start/end timestamps and total run duration for calculating improvement percentages
projectRoot string No Project root path used to convert absolute file paths to relative paths in report links

Outputs

Name Type Description
return string Complete markdown report content including summary tables, file-based fixes, workspace-wide optimizations, performance warnings, and an implementation guide

Usage Examples

Generating a Markdown Report

import { generateMarkdownReport } from './markdown-formatter.js'
import fs from 'node:fs'

const optimizedSelectors = [
    {
        selector: '//XCUIElementTypeButton[@name="Login"]',
        optimizedSelector: '~Login',
        improvementMs: 45.2,
        improvementPercent: 68.5,
        duration: 66.0,
        optimizedDuration: 20.8,
        selectorFile: '/project/tests/pageobjects/login.page.ts',
        lineNumber: 12,
        testFile: 'tests/specs/login.spec.ts',
        suiteName: 'Login Suite',
        testName: 'should login successfully',
        timestamp: Date.now()
    }
]

const report = generateMarkdownReport(
    optimizedSelectors,
    'iPhone 15 Pro',
    { startTime: 1700000000000, endTime: 1700000060000, totalRunDurationMs: 60000 },
    process.cwd()
)

fs.writeFileSync('./reports/selector-report.md', report)

Related Pages

Page Connections

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