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 BrowserStack Reporter

From Leeroopedia
Revision as of 11:56, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Webdriverio_Webdriverio_BrowserStack_Reporter.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains BrowserStack, Reporting
Last Updated 2026-02-12 00:00 GMT

Overview

The TestReporter class extends WDIOReporter to capture test execution events for BrowserStack Test Reporting and Analytics, primarily handling Jasmine and mocha skip events.

Description

The _TestReporter class (exported as TestReporter via o11yClassErrorHandler) extends the base WDIOReporter and is added to the reporters list when Test Reporting and Analytics (testhub) events need to be processed. It tracks runner start, suite start/end, test start/end/skip, and hook start/end events. The reporter builds TestData objects with scope hierarchies, file paths, git metadata, integration details, and dispatches them through the Listener. It uses a needToSendData method to selectively process events per framework (Jasmine gets full events, mocha only skips, cucumber is handled by InsightsHandler).

Usage

This reporter is automatically pushed into the config.reporters array by BrowserstackService when testhub event processing is enabled. It runs in the worker process and collects events that are not handled by the InsightsHandler (primarily Jasmine tests and mocha skip events).

Code Reference

Source Location

Signature

class _TestReporter extends WDIOReporter {
    public static currentTest: CurrentRunInfo
    public static hashCodeToHandleTestSkip: Record<string, string>

    async onRunnerStart(runnerStats: RunnerStats): Promise<void>
    onSuiteStart(suiteStats: SuiteStats): void
    onSuiteEnd(): void
    async onTestStart(testStats: TestStats): Promise<void>
    async onTestEnd(testStats: TestStats): Promise<void>
    async onHookStart(hookStats: HookStats): Promise<void>
    async onHookEnd(hookStats: HookStats): Promise<void>
    async onTestSkip(testStats: TestStats): Promise<void>
    async getRunData(testStats: TestStats | HookStats, eventType: string): Promise<TestData>
    static getTests(): Record<string, TestMeta>
}

Import

import TestReporter from './reporter.js'

I/O Contract

Inputs

Name Type Required Description
runnerStats RunnerStats Yes Runner statistics with capabilities, config, and session ID (received in onRunnerStart)
suiteStats SuiteStats Yes Suite statistics with title and file information (received in onSuiteStart)
testStats TestStats Yes Test statistics with title, fullTitle, state, error, timing (received in test events)
hookStats HookStats Yes Hook statistics with title, state, and error (received in hook events)

Outputs

Name Type Description
TestData events TestData Dispatched through Listener for test start, finish, skip, hook start, and hook finish events
TestReporter.currentTest CurrentRunInfo Static reference to current test UUID
TestReporter.hashCodeToHandleTestSkip Record<string, string> Mapping of test hash codes to UUIDs for deduplicating skip events

Usage Examples

Reporter automatically added to config

// Inside BrowserstackService constructor
if (shouldProcessEventForTesthub('')) {
    this._config.reporters?.push(TestReporter)
}

Accessing static test data from InsightsHandler

// InsightsHandler can reference reporter test metadata
const testMeta = this._tests[identifier] || TestReporter.getTests()[identifier]

Related Pages

Page Connections

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