Skip to main content

Introduction

Welcome to wdio-api-runner — a specialized WebdriverIO runner designed for high-performance API automation testing. This runner eliminates the overhead of browser sessions, making your API tests faster, lighter, and easier to maintain.

What is wdio-api-runner?

wdio-api-runner is a custom test runner for the WebdriverIO test automation framework. While WebdriverIO is traditionally used for browser-based testing, many teams also need to test REST APIs, GraphQL endpoints, and backend services. Running these tests through a browser session is wasteful and slow.

wdio-api-runner solves this problem by providing a dedicated runner that:

  • Skips browser initialization entirely
  • Provides a built-in HTTP client optimized for API testing
  • Maintains full compatibility with WebdriverIO's ecosystem (reporters, services, frameworks)
  • Supports parallel test execution out of the box

Why Choose wdio-api-runner?

The Problem with Browser-Based API Testing

Traditional WebdriverIO testing spins up browser sessions for every test—even when you're just testing APIs. This creates significant overhead:

MetricBrowser RunnerAPI RunnerImprovement
Startup time~2-5 seconds~50ms40-100x faster
Memory per worker~200-500MB~30MB7-17x less memory
DependenciesBrowser + DriverNoneZero external deps
CI/CD complexityHighMinimalSimpler pipelines
Docker image size~1-2GB~200MB5-10x smaller

Real-World Impact

Consider a test suite with 500 API tests running on 10 parallel workers:

With Browser Runner:

  • Startup: 10 workers × 3s = 30 seconds wasted
  • Memory: 10 workers × 300MB = 3GB RAM required
  • CI time: Additional browser installation steps

With API Runner:

  • Startup: 10 workers × 50ms = 0.5 seconds
  • Memory: 10 workers × 30MB = 300MB RAM required
  • CI time: No browser installation needed

Result: Faster feedback loops, lower infrastructure costs, and simpler CI/CD pipelines.

Key Features

Core Capabilities

FeatureDescription
Zero Browser OverheadNo WebDriver protocol, no browser binaries, no session management. Tests start instantly.
Native Fetch API ClientModern, Promise-based HTTP client built on the Fetch API with full TypeScript support.
Parallel ExecutionFull support for WebdriverIO's parallel worker architecture. Run hundreds of tests simultaneously.
All Reporters WorkSpec, Allure, JUnit, HTML—every WDIO reporter works without modification.
All Frameworks WorkMocha, Jasmine, Cucumber—use your preferred test framework.
Service CompatibleUse WDIO services for setup/teardown, database seeding, mock servers, etc.

API Testing Features

FeatureDescription
Fluent AssertionsChain assertions for status codes, headers, body content, and JSON schema validation.
Authentication HelpersBuilt-in support for Basic Auth, API Keys, Bearer/JWT tokens, and OAuth2 flows.
Request InterceptorsAdd global middleware for authentication, logging, request modification, and more.
Retry & TimeoutConfigurable request retries with exponential backoff and custom timeout handling.
Response TimingAutomatic request duration tracking for performance monitoring.

GraphQL Support

FeatureDescription
GraphQL ClientDedicated client for queries, mutations, and subscriptions with proper error handling.
Query BuilderFluent API for building complex GraphQL operations programmatically.
Real-time SubscriptionsWebSocket and Server-Sent Events (SSE) support for GraphQL subscriptions.
Type SafetyFull TypeScript generics support for typed query responses.

Observability & Debugging

FeatureDescription
HAR LoggingRecord all HTTP traffic to HAR format for debugging, replay, and analysis.
Performance MetricsTrack p50/p95/p99 latency percentiles with threshold-based CI checks.
Grouped LogsOptional log grouping by test spec for cleaner CI output.
Verbose ModeDetailed request/response logging for debugging.

Architecture Overview

┌─────────────────────────────────────────────────────────────┐
│ Your Test Files │
│ describe('Users API', () => { ... }) │
└─────────────────────────────────────────────────────────────┘


┌─────────────────────────────────────────────────────────────┐
│ wdio-api-runner │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ API Client │ │ GraphQL │ │ Auth │ │
│ │ (Fetch) │ │ Client │ │ Helpers │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Assertions │ │ Metrics │ │ HAR Logger │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
└─────────────────────────────────────────────────────────────┘


┌─────────────────────────────────────────────────────────────┐
│ WebdriverIO Core │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Reporters │ │ Services │ │ Parallel │ │
│ │ (Spec,Allure│ │ (Custom) │ │ Workers │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
└─────────────────────────────────────────────────────────────┘


┌─────────────────────────────────────────────────────────────┐
│ Your API Server │
│ https://api.example.com │
└─────────────────────────────────────────────────────────────┘

Comparison with Alternatives

vs. Browser-Based API Testing

Aspectwdio-api-runnerBrowser Runner
Speed⚡ ~50ms startup🐢 ~2-5s startup
Memory💾 ~30MB💾 ~200-500MB
Dependencies✅ None❌ Browser + Driver
CORS✅ No restrictions❌ Browser rules apply
Cookies🔧 Manual✅ Automatic
CI Setup✅ Simple⚠️ Complex

vs. Standalone API Testing Tools

Aspectwdio-api-runnerStandalone Tools
WDIO Integration✅ Native❌ Separate tool
Parallel Execution✅ Built-in⚠️ Manual setup
Reporting✅ All WDIO reporters⚠️ Limited
Test Organization✅ Specs, suites⚠️ Varies
Learning Curve✅ Same as WDIO⚠️ New tool to learn

Use Cases

Ideal For

  • Backend API Testing — Test REST endpoints without browser overhead
  • Microservices Testing — Validate service-to-service communication
  • GraphQL Testing — Full support for queries, mutations, and subscriptions
  • Contract Testing — Verify API contracts with schema validation
  • Performance Testing — Track latency percentiles and set thresholds
  • CI/CD Pipelines — Fast, lightweight tests for continuous integration

Not Ideal For

  • End-to-End UI Testing — Use standard WebdriverIO for browser testing
  • Visual Regression Testing — Requires actual browser rendering
  • JavaScript-Heavy SPAs — When you need to test client-side behavior

Getting Started

Ready to start testing? Head to the Installation Guide to set up wdio-api-runner in your project.

npm install wdio-api-runner --save-dev

Then configure your wdio.conf.ts:

export const config: WebdriverIO.Config = {
runner: 'api',
specs: ['./test/api/**/*.spec.ts'],
// ... rest of your config
}

Next Steps