Principle:Webdriverio Webdriverio Test Result Reporting
Overview
A mechanism for formatting and presenting test execution results to users and CI systems.
Metadata
| Field | Value |
|---|---|
| Page Type | Principle |
| Repository | webdriverio/webdriverio |
| Knowledge Sources | Repo (GitHub), Doc (Spec Reporter) |
| Domains | Testing, Reporting |
| Related Implementations | Implementation: SpecReporter_Class |
Description
Test Result Reporting collects test execution events (suite start/end, test pass/fail/skip, hook execution) and transforms them into human-readable or machine-parseable output. Reporters serve as the feedback channel between test execution and developers/CI pipelines, enabling quick identification of failures and tracking of test health over time.
In the WDIO architecture, reporters operate within each worker process, receiving real-time events from the framework adapter (Mocha, Jasmine, or Cucumber) as tests execute. They maintain internal state about suites, tests, hooks, and timing, then produce formatted output when the runner completes. The output can be directed to stdout (console reporters), files (JUnit XML, JSON), or external services (Allure, ReportPortal).
WDIO supports multiple simultaneous reporters. They are configured in the reporters array of the configuration file and are instantiated by the runner for each worker process.
Usage
Use to see test results during and after execution. Configure in wdio.conf.ts via the reporters array:
// wdio.conf.ts
export const config: WebdriverIO.Config = {
reporters: [
// String form: use defaults
'spec',
// Array form: with options
['junit', {
outputDir: './test-results',
outputFileFormat: function(options) {
return `results-${options.cid}.xml`
}
}],
// Allure for rich HTML reports
['allure', {
outputDir: 'allure-results',
disableWebdriverStepsReporting: true
}]
],
// ...
}
The spec reporter is the most common choice for local development, providing colored console output. The JUnit reporter is standard for CI integration (Jenkins, GitHub Actions, etc.). The Allure reporter produces rich, interactive HTML reports.
Theoretical Basis
Observer Pattern
Reporters implement the observer pattern: they subscribe to test lifecycle events emitted by the test runner framework adapter. Each event carries a stats object with timing, error details, and metadata. The event flow is:
runner:start-- a worker process begins (includes capabilities, session info)suite:start-- a describe/feature block beginshook:start/hook:end-- before/after hooks executetest:start-- an individual test beginstest:pass/test:fail/test:pending-- test outcometest:end-- test completes (regardless of outcome)suite:end-- describe/feature block completesrunner:end-- worker process finishes (final summary)
WDIOReporter Base Class
The WDIOReporter base class (from @wdio/reporter) manages:
- Event subscription -- automatically binds
on<EventName>methods to the corresponding events - Output streams -- writes to stdout by default, or to a file via
outputDiroption - State tracking -- maintains maps of suites, tests, hooks, and their stats (RunnerStats, SuiteStats, TestStats, HookStats)
- Timing -- records start/end timestamps and computes durations
Custom reporters extend WDIOReporter and override event handler methods (onRunnerStart, onTestPass, onTestFail, onRunnerEnd, etc.) to produce any desired output format.
Stats Objects
Each event handler receives a typed stats object:
| Stats Type | Key Properties |
|---|---|
RunnerStats |
cid, capabilities, sessionId, specs, config, instanceOptions, _duration |
SuiteStats |
uid, title, file, tests, hooks, suites, hooksAndTests, duration, retries |
TestStats |
uid, title, fullTitle, state (passed/failed/skipped/pending), duration, errors, retries, argument |
HookStats |
uid, title, state, error, duration |
Output Formatting
Reporters control all aspects of output formatting:
- Symbols: Pass/fail/skip indicators (default: checkmark, X, dash)
- Colors: Chalk-based coloring (green=pass, red=fail, cyan=skip, yellow=retry)
- Hierarchy: Indentation reflecting describe/it nesting
- Error details: Stack traces for failures, diff output for assertion errors
- Summary: Aggregate pass/fail/skip counts with total duration
Available Reporters
| Reporter | Package | Output | Use Case |
|---|---|---|---|
| Spec | @wdio/spec-reporter |
Colored console | Local development |
| Dot | @wdio/dot-reporter |
Dot-based console | Minimal output |
| JUnit | @wdio/junit-reporter |
XML files | CI systems (Jenkins, GitHub Actions) |
| Allure | @wdio/allure-reporter |
JSON files -> HTML | Rich interactive reports |
| JSON | @wdio/json-reporter |
JSON files | Custom processing |
| Concise | @wdio/concise-reporter |
Brief console | Quick overview |
Related Pages
Implementation:Webdriverio_Webdriverio_SpecReporter_Class
- Implemented by: Implementation: SpecReporter_Class
- Receives events from: Principle: Test_Execution_Orchestration
- Reports on: Principle: Test_Spec_Authoring