or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

capabilities.mdframeworks.mdindex.mdnetwork.mdoptions.mdreporters.mdservices.mdworkers.md
tile.json

tessl/npm-wdio--types

Utility package providing comprehensive TypeScript type definitions for the WebdriverIO ecosystem

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/@wdio/types@9.19.x

To install, run

npx @tessl/cli install tessl/npm-wdio--types@9.19.0

index.mddocs/

WebdriverIO Types

WebdriverIO Types is a comprehensive TypeScript type definition package that provides type safety and IntelliSense support for the entire WebdriverIO ecosystem. It includes type definitions for browser capabilities, test runner configuration, service extensions, framework integrations, reporter options, and worker communication, enabling type-safe development for browser automation and testing.

Package Information

  • Package Name: @wdio/types
  • Package Type: npm
  • Language: TypeScript
  • Installation: npm install @wdio/types

Core Imports

import type { Automation, Capabilities, Options, Services, Frameworks, Reporters, Workers, Network } from "@wdio/types";
import { MESSAGE_TYPES } from "@wdio/types";

For CommonJS:

const { MESSAGE_TYPES } = require("@wdio/types");

Basic Usage

import type { Capabilities, Options } from "@wdio/types";

// Define WebDriver capabilities with type safety
const capabilities: Capabilities.W3CCapabilities = {
  alwaysMatch: {
    browserName: "chrome",
    "goog:chromeOptions": {
      args: ["--headless"]
    }
  },
  firstMatch: []
};

// Configure WebdriverIO options
const config: Options.Testrunner = {
  specs: ["./test/**/*.spec.ts"],
  capabilities: [capabilities],
  framework: "mocha",
  reporters: ["spec"]
};

Architecture

WebdriverIO Types is organized around key WebdriverIO ecosystem components:

  • Capabilities Module: Browser and device configuration types for WebDriver sessions
  • Options Module: Configuration types for WebdriverIO client and test runner
  • Services Module: Extension point types for WebdriverIO services and lifecycle hooks
  • Frameworks Module: Test framework integration types (Mocha, Jasmine, Cucumber)
  • Reporters Module: Test result reporting configuration types
  • Workers Module: Test execution and inter-process communication types
  • Automation Module: Generic driver interfaces for WebDriver implementations
  • Network Module: Network request and cookie types for WebDriver Bidi

Capabilities

Browser Capabilities

WebDriver capabilities and browser-specific configuration options for Chrome, Firefox, Safari, Edge, and mobile devices.

namespace Capabilities {
  interface W3CCapabilities {
    alwaysMatch?: WebdriverIO.Capabilities;
    firstMatch?: WebdriverIO.Capabilities[];
  }
  
  type RequestedStandaloneCapabilities = W3CCapabilities | WebdriverIO.Capabilities;
}

Browser Capabilities

Configuration Options

WebdriverIO client and test runner configuration including connection settings, logging, and test execution options.

namespace Options {
  interface Testrunner extends Hooks, WebdriverIO {
    specs?: string[];
    exclude?: string[];
    suites?: Record<string, string[]>;
    capabilities: TestrunnerCapabilities;
    framework: string;
    reporters?: ReporterEntry[];
  }
}

Configuration Options

Services and Hooks

Service extension interfaces and comprehensive lifecycle hook definitions for extending WebdriverIO functionality.

namespace Services {
  interface HookFunctions {
    onPrepare?(config: Options.Testrunner, capabilities: TestrunnerCapabilities): void | Promise<void>;
    onComplete?(exitCode: number, config: Options.Testrunner, capabilities: TestrunnerCapabilities): void | Promise<void>;
    before?(capabilities: WebdriverIO.Capabilities, specs: string[], browser: WebdriverIO.Browser): void | Promise<void>;
    after?(result: number, capabilities: WebdriverIO.Capabilities, specs: string[]): void | Promise<void>;
  }
}

Services and Hooks

Test Frameworks

Test framework integration types supporting Mocha, Jasmine, and Cucumber with test execution results and metadata.

namespace Frameworks {
  interface Test extends Suite {
    fullName: string;
    fn?: Function;
    body?: string;
    async?: number;
    sync?: boolean;
  }
  
  interface TestResult {
    error?: any;
    result?: any;
    passed: boolean;
    duration: number;
    retries: TestRetries;
  }
}

Test Frameworks

Reporters

Test result reporting configuration with output formatting and custom reporter support.

namespace Reporters {
  interface Options {
    outputDir?: string;
    logFile?: string;
    outputFileFormat?: (options: OutputFileFormatOptions) => string;
    stdout?: boolean;
  }
  
  type ReporterEntry = string | ReporterClass | [string, WebdriverIO.ReporterOption] | [ReporterClass, WebdriverIO.ReporterOption];
}

Reporters

Workers and Messaging

Worker process management and inter-process communication for test execution in parallel environments.

namespace Workers {
  interface Worker extends EventEmitter {
    capabilities: WebdriverIO.Capabilities;
    config: Options.Testrunner;
    cid: string;
    postMessage: (command: string, args: WorkerMessageArgs) => void;
  }
  
  enum MESSAGE_TYPES {
    consoleMessage = 0,
    commandRequestMessage,
    commandResponseMessage
  }
}

Workers and Messaging

Automation Drivers

Generic driver interfaces for WebDriver implementations and session management.

namespace Automation {
  interface Driver<T> {
    newSession(options: T, modifier?: (...args: unknown[]) => unknown, userPrototype?: Record<string, unknown>, customCommandWrapper?: (...args: unknown[]) => unknown): unknown;
    attachToSession(options: unknown, modifier?: (...args: unknown[]) => unknown, userPrototype?: Record<string, unknown>, customCommandWrapper?: (...args: unknown[]) => unknown): unknown;
    reloadSession(client: unknown, newCapabilities: WebdriverIO.Capabilities): unknown;
  }
}

Network Requests

Network request and cookie types for WebDriver Bidi protocol.

namespace Network {
  interface Request {
    id?: string;
    url: string;
    timestamp: number;
    navigation?: string;
    redirectChain?: string[];
    headers: Record<string, string>;
    cookies?: NetworkCookie[];
    error?: string;
    response?: {
      fromCache: boolean;
      headers: Record<string, string>;
      mimeType: string;
      status: number;
    };
    children?: Request[];
  }
  
  interface NetworkCookie {
    name: string;
    value: string;
    domain: string;
    path: string;
    size: number;
    httpOnly: boolean;
    secure: boolean;
    sameSite: 'strict' | 'lax' | 'none';
    expiry?: number;
  }
}

Utility Types

Core utility types for JSON serialization, function property extraction, and Promise resolution:

type JsonPrimitive = string | number | boolean | null;
type JsonObject = { [x: string]: JsonPrimitive | JsonObject | JsonArray };
type JsonArray = Array<JsonPrimitive | JsonObject | JsonArray>;
type JsonCompatible = JsonObject | JsonArray;

type FunctionPropertyNames<T> = { [K in keyof T]: T[K] extends Function ? K : never }[keyof T];
type FunctionProperties<T> = Pick<T, FunctionPropertyNames<T>>;
type ThenArg<T> = T extends PromiseLike<infer U> ? U : T;

Global Namespace Extensions

The package extends the global WebdriverIO namespace, allowing ecosystem packages to augment interfaces:

declare global {
  namespace WebdriverIO {
    interface ServiceOption extends Services.ServiceOption {}
    interface ReporterOption extends Reporters.Options {}
    interface Browser {
      requestedCapabilities?: any;
    }
    interface MultiRemoteBrowser {}
    interface Element {
      parent: WebdriverIO.Element | WebdriverIO.Browser;
    }
    interface MultiRemoteElement {}
    interface ElementArray {}
    interface Request extends Network.Request {}
    interface MochaOpts { [key: string]: any }
    interface JasmineOpts { [key: string]: any }
    interface CucumberOpts { [key: string]: any }
    interface Config extends Options.Testrunner, Capabilities.WithRequestedTestrunnerCapabilities {}
    interface RemoteConfig extends Options.WebdriverIO, Capabilities.WithRequestedCapabilities {}
    interface MultiremoteConfig extends Options.Testrunner, Capabilities.WithRequestedMultiremoteCapabilities {}
    interface HookFunctionExtension {}
    interface WDIOVSCodeServiceOptions {}
    interface BrowserRunnerOptions {}
    interface ChromedriverOptions {}
    interface GeckodriverOptions {}
    interface EdgedriverOptions {}
    interface SafaridriverOptions {}
  }
}