CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-wdio--types

Utility package providing comprehensive TypeScript type definitions for the WebdriverIO ecosystem

Pending
This version of the tile failed moderation
Malicious code detected in tile.json: This is a typosquatting/dependency confusion attack. The package 'tessl/npm-wdio--types' mimics the legitimate '@wdio/types' package (a WebdriverIO TypeScript definitions package). The naming pattern 'npm-wdio--types' with double dashes is designed to confuse users or automated systems into installing this instead of the real '@wdio/types@9.19.2' package. The 'describes' field explicitly references the legitimate package it's impersonating.
Overview
Eval results
Files

services.mddocs/

Services and Hooks

Service extension interfaces and comprehensive lifecycle hook definitions for extending WebdriverIO functionality with custom behaviors and integrations.

Capabilities

Service Definition

Service class and plugin interfaces for extending WebdriverIO functionality.

/**
 * Service options interface - extended by individual services
 */
interface ServiceOption {
  [key: string]: any;
}

/**
 * Service class constructor
 */
interface ServiceClass {
  new(
    options: WebdriverIO.ServiceOption,
    capabilities: ResolvedTestrunnerCapabilities,
    config: WebdriverIOOptions
  ): ServiceInstance;
}

/**
 * Service plugin with optional launcher
 */
interface ServicePlugin extends ServiceClass {
  /** Default service class */
  default: ServiceClass;
  /** Optional launcher service */
  launcher?: ServiceClass;
}

/**
 * Service instance interface
 */
interface ServiceInstance extends HookFunctions {
  /** Service configuration options */
  options?: Record<string, any>;
  /** Associated capabilities */
  capabilities?: WebdriverIO.Capabilities;
  /** WebdriverIO configuration */
  config?: TestrunnerOptions;
}

Service Entry Types

Different ways to configure services in WebdriverIO.

/**
 * Service configuration options
 */
type ServiceEntry = 
  /** Service name as string */
  | string
  /** Service as hook functions object */
  | HookFunctions
  /** Service class */
  | ServiceClass
  /** Service name with options */
  | [string, WebdriverIO.ServiceOption]
  /** Service class with options */
  | [ServiceClass, WebdriverIO.ServiceOption];

Hook Functions

Comprehensive lifecycle hook definitions for WebdriverIO test execution.

/**
 * Complete hook function interface
 */
interface HookFunctions {
  /**
   * Executed before a test run starts. Has access to all config options and capabilities.
   */
  onPrepare?(
    config: Options.Testrunner,
    capabilities: TestrunnerCapabilities
  ): void | Promise<void>;

  /**
   * Executed after all tests are completed. Has access to exit code and config.
   */
  onComplete?(
    exitCode: number,
    config: Options.Testrunner,
    capabilities: TestrunnerCapabilities,
    results: Results
  ): void | Promise<void>;

  /**
   * Executed when a worker process starts.
   */
  onWorkerStart?(
    cid: string,
    caps: WebdriverIO.Capabilities,
    specs: string[],
    args: WorkerMessageArgs,
    execArgv: string[]
  ): void | Promise<void>;

  /**
   * Executed when a worker process ends.
   */
  onWorkerEnd?(
    cid: string,
    exitCode: number,
    specs: string[],
    retries: number
  ): void | Promise<void>;

  /**
   * Executed before a WebDriver session starts.
   */
  before?(
    capabilities: WebdriverIO.Capabilities,
    specs: string[],
    browser: WebdriverIO.Browser
  ): void | Promise<void>;

  /**
   * Executed after a WebDriver session ends.
   */
  after?(
    result: number,
    capabilities: WebdriverIO.Capabilities,
    specs: string[]
  ): void | Promise<void>;

  /**
   * Executed before session starts (WebDriver level).
   */
  beforeSession?(
    config: Options.Testrunner,
    capabilities: WebdriverIO.Capabilities,
    specs: string[],
    cid: string
  ): void | Promise<void>;

  /**
   * Executed after session ends (WebDriver level).
   */
  afterSession?(
    config: Options.Testrunner,
    capabilities: WebdriverIO.Capabilities,
    specs: string[]
  ): void | Promise<void>;

  /**
   * Executed when a session is reloaded.
   */
  onReload?(
    oldSessionId: string,
    newSessionId: string
  ): void | Promise<void>;

  /**
   * Executed before a test suite starts.
   */
  beforeSuite?(suite: Suite): void | Promise<void>;

  /**
   * Executed after a test suite ends.
   */
  afterSuite?(suite: Suite): void | Promise<void>;

  /**
   * Executed before a test starts.
   */
  beforeTest?(
    test: Test,
    context: any
  ): void | Promise<void>;

  /**
   * Executed after a test ends.
   */
  afterTest?(
    test: Test,
    context: any,
    result: TestResult
  ): void | Promise<void>;

  /**
   * Executed before a hook starts.
   */
  beforeHook?(
    test: Test,
    context: any,
    stepData?: any,
    world?: World
  ): void | Promise<void>;

  /**
   * Executed after a hook ends.
   */
  afterHook?(
    test: Test,
    context: any,
    result: TestResult,
    stepData?: any,
    world?: World
  ): void | Promise<void>;

  /**
   * Executed before a WebDriver command.
   */
  beforeCommand?(
    commandName: string,
    args: any[]
  ): void | Promise<void>;

  /**
   * Executed after a WebDriver command.
   */
  afterCommand?(
    commandName: string,
    args: any[],
    result: any,
    error?: Error
  ): void | Promise<void>;

  /**
   * Executed before an assertion/expectation.
   */
  beforeAssertion?(params: AssertionHookParams): void | Promise<void>;

  /**
   * Executed after an assertion/expectation.
   */
  afterAssertion?(params: AfterAssertionHookParams): void | Promise<void>;
}

Assertion Hook Parameters

Parameters passed to assertion-related hooks.

/**
 * Parameters for assertion hooks
 */
interface AssertionHookParams {
  /** Name of the matcher (e.g., 'toHaveText', 'toBeClickable') */
  matcherName: string;
  /** Value passed by user to the matcher */
  expectedValue?: any;
  /** Options passed to the matcher */
  options: object;
}

/**
 * Parameters for after assertion hooks
 */
interface AfterAssertionHookParams extends AssertionHookParams {
  /** Assertion result */
  result: {
    /** Function returning the assertion message */
    message: () => string;
    /** Boolean result of the assertion */
    result: boolean;
  };
}

Hook Type Helpers

Type definitions for hook function arrays and single values.

/**
 * Hook functions supporting single or array values
 */
type Hooks = {
  [K in keyof HookFunctions]: HookFunctions[K] | HookFunctions[K][];
};

Runner Interface

Test runner instance and class interfaces.

/**
 * Test runner instance
 */
interface RunnerInstance {
  /** Initialize the runner */
  initialize(): Promise<void>;
  /** Shutdown the runner */
  shutdown(): Promise<boolean>;
  /** Close a specific session */
  closeSession?(cid: number): Promise<void>;
  /** Get worker count */
  getWorkerCount(): number;
  /** Run tests */
  run(args: any): Worker;
  /** Worker pool */
  workerPool: any;
  /** Browser pool */
  browserPool: any;
}

/**
 * Test runner class constructor
 */
interface RunnerClass {
  new(
    options: WebdriverIO.BrowserRunnerOptions,
    config: Omit<WebdriverIOOptions, 'capabilities' | keyof Hooks>
  ): RunnerInstance;
}

/**
 * Runner plugin with launcher support
 */
interface RunnerPlugin extends RunnerClass {
  /** Default runner class */
  default: RunnerClass;
  /** Optional launcher class */
  launcher?: RunnerClass;
}

Usage Examples:

import type { Services } from "@wdio/types";

// Custom service implementation
class CustomService implements Services.ServiceInstance {
  constructor(
    private options: Services.ServiceOption,
    private capabilities: any,
    private config: any
  ) {}

  async onPrepare(config: any, capabilities: any) {
    console.log('Setting up custom service...');
    // Custom setup logic
  }

  async before(capabilities: any, specs: string[], browser: any) {
    console.log('Starting test session...');
    // Session initialization
  }

  async beforeTest(test: any, context: any) {
    console.log(`Starting test: ${test.title}`);
    // Pre-test setup
  }

  async afterTest(test: any, context: any, result: any) {
    console.log(`Test completed: ${test.title}, passed: ${result.passed}`);
    // Post-test cleanup
  }

  async after(result: number, capabilities: any, specs: string[]) {
    console.log('Ending test session...');
    // Session cleanup
  }

  async onComplete(exitCode: number, config: any, capabilities: any) {
    console.log('Custom service cleanup complete');
    // Final cleanup
  }
}

// Service configuration
const services: Services.ServiceEntry[] = [
  'chromedriver',
  ['@wdio/selenium-standalone-service', { installArgs: { drivers: { chrome: true } } }],
  [CustomService, { customOption: true }],
  {
    beforeTest: (test, context) => {
      console.log(`Running test: ${test.title}`);
    },
    afterTest: (test, context, result) => {
      if (!result.passed) {
        console.log(`Test failed: ${test.title}`);
      }
    }
  }
];

Install with Tessl CLI

npx tessl i tessl/npm-wdio--types

docs

capabilities.md

frameworks.md

index.md

network.md

options.md

reporters.md

services.md

workers.md

tile.json