Utility package providing comprehensive TypeScript type definitions for the WebdriverIO ecosystem
—
Test framework integration types supporting Mocha, Jasmine, and Cucumber with test execution results, metadata, and framework-specific structures.
Core test suite interface used across all frameworks.
/**
* Test suite information
*/
interface Suite {
/** Suite type identifier */
type: string;
/** Suite title/name */
title: string;
/** Parent suite identifier */
parent: string;
/** Full hierarchical title */
fullTitle: string;
/** Whether suite is pending/skipped */
pending: boolean;
/** Source file path */
file: string;
/** Error information if suite failed */
error?: any;
/** Suite execution duration in milliseconds */
duration?: number;
}Individual test case interface extending suite information.
/**
* Individual test case information
*/
interface Test extends Suite {
/** Full test name including suite hierarchy */
fullName: string;
/** Test function reference */
fn?: Function;
/** Test function body as string */
body?: string;
/** Async test indicator */
async?: number;
/** Synchronous test flag */
sync?: boolean;
/** Whether test timed out */
timedOut?: boolean;
/** Test execution context */
ctx: any;
// Mocha-specific properties
/** Test description */
description?: string;
/** Retried test reference */
_retriedTest?: any;
/** Current retry attempt */
_currentRetry?: number;
/** Maximum retry attempts */
_retries?: number;
}Test execution outcome and metadata.
/**
* Test retry information
*/
interface TestRetries {
/** Maximum retry attempts allowed */
limit: number;
/** Number of retry attempts made */
attempts: number;
}
/**
* Test execution result
*/
interface TestResult {
/** Error information if test failed */
error?: any;
/** Test result data */
result?: any;
/** Whether test passed */
passed: boolean;
/** Test execution duration in milliseconds */
duration: number;
/** Retry information */
retries: TestRetries;
/** Exception details as string */
exception: string;
/** Test status */
status: string;
}
/**
* Test run summary statistics
*/
interface Results {
/** Number of completed tests */
finished: number;
/** Number of passed tests */
passed: number;
/** Number of failed tests */
failed: number;
}Cucumber-specific test framework types for BDD testing.
/**
* Cucumber world object
*/
interface World {
/** Pickle (scenario) information */
pickle: {
/** Scenario name */
name?: string;
};
/** Scenario execution result */
result?: {
/** Execution duration */
duration: {
seconds: number;
nanos: number;
};
/** Scenario status */
status: 'UNKNOWN' | 'PASSED' | 'SKIPPED' | 'PENDING' | 'UNDEFINED' | 'AMBIGUOUS' | 'FAILED';
/** Error message if failed */
message?: string;
/** Whether scenario will be retried */
willBeRetried: boolean;
};
}
/**
* Cucumber pickle (scenario/step) result
*/
interface PickleResult {
/** Whether scenario passed */
passed: boolean;
/** Error stack if scenario failed */
error?: string;
/** Scenario duration in milliseconds */
duration?: number;
}
/**
* Cucumber step information
*/
interface PickleStep {
/** Step identifier */
id: string;
/** Step text */
text: string;
/** AST node identifiers */
astNodeIds: string[];
/** Step keyword with trailing space */
keyword: 'Given ' | 'When ' | 'Then ' | 'And ';
}
/**
* Cucumber tag information
*/
interface Tag {
/** Tag name */
name: string;
/** AST node identifier */
astNodeId: string;
}
/**
* Cucumber scenario information
*/
interface Scenario {
/** Scenario identifier */
id: string;
/** Feature file URI */
uri: string;
/** Scenario name */
name: string;
/** AST node identifiers */
astNodeIds: string[];
/** Scenario steps */
steps: PickleStep[];
/** Scenario tags */
tags: Tag[];
}Global namespace extensions for framework-specific options.
declare global {
namespace WebdriverIO {
/**
* Mocha test framework options
*/
interface MochaOpts {
/** Test timeout in milliseconds */
timeout?: number;
/** Enable bail (stop on first failure) */
bail?: boolean;
/** Test UI (bdd, tdd, exports) */
ui?: string;
/** Grep pattern for test filtering */
grep?: string;
/** Invert grep pattern */
invert?: boolean;
/** Require modules before running tests */
require?: string[];
/** Mocha reporter */
reporter?: string;
/** Reporter options */
reporterOptions?: Record<string, any>;
/** Enable recursive file search */
recursive?: boolean;
/** Slow test threshold in milliseconds */
slow?: number;
/** Number of times to retry failed tests */
retries?: number;
[key: string]: any;
}
/**
* Jasmine test framework options
*/
interface JasmineOpts {
/** Default test timeout in milliseconds */
defaultTimeoutInterval?: number;
/** Helper files to load */
helpers?: string[];
/** Require modules before running tests */
requires?: string[];
/** Enable random test execution order */
random?: boolean;
/** Seed for random test order */
seed?: number;
/** Stop on first failure */
stopOnFailure?: boolean;
/** Enable one failure per spec */
oneFailurePerSpec?: boolean;
/** Spec files to include */
specFilter?: (spec: string) => boolean;
/** Grep pattern for test filtering */
grep?: string | RegExp;
/** Invert grep pattern */
invertGrep?: boolean;
[key: string]: any;
}
/**
* Cucumber test framework options
*/
interface CucumberOpts {
/** Feature files to include */
require?: string[];
/** Require modules before running tests */
requireModule?: string[];
/** Cucumber tags to include/exclude */
tags?: string;
/** Strict mode (fail on undefined steps) */
strict?: boolean;
/** Dry run (don't execute steps) */
dryRun?: boolean;
/** Fail fast (stop on first failure) */
failFast?: boolean;
/** Step timeout in milliseconds */
timeout?: number;
/** Number of times to retry failed scenarios */
retry?: number;
/** Retry only tagged scenarios */
retryTagFilter?: string;
/** World parameters */
worldParameters?: Record<string, any>;
/** Cucumber profile */
profile?: string[];
/** Name pattern for scenario filtering */
name?: string[];
/** Scenario line numbers */
scenarioLevelReporter?: boolean;
[key: string]: any;
}
}
}Usage Examples:
import type { Frameworks } from "@wdio/types";
// Custom test reporter using framework types
class CustomReporter {
onTestStart(test: Frameworks.Test) {
console.log(`Starting test: ${test.fullTitle}`);
}
onTestEnd(test: Frameworks.Test, result: Frameworks.TestResult) {
const status = result.passed ? 'PASSED' : 'FAILED';
console.log(`${status}: ${test.fullTitle} (${result.duration}ms)`);
if (!result.passed && result.error) {
console.error('Error:', result.error.message);
}
if (result.retries.attempts > 0) {
console.log(`Retried ${result.retries.attempts} times`);
}
}
onSuiteEnd(suite: Frameworks.Suite) {
console.log(`Suite completed: ${suite.fullTitle}`);
if (suite.duration) {
console.log(`Total duration: ${suite.duration}ms`);
}
}
onRunnerEnd(results: Frameworks.Results) {
console.log(`\nTest Summary:`);
console.log(`Total: ${results.finished}`);
console.log(`Passed: ${results.passed}`);
console.log(`Failed: ${results.failed}`);
}
}
// Cucumber step result handler
function handleCucumberStep(
step: Frameworks.PickleStep,
result: Frameworks.PickleResult
) {
const status = result.passed ? '✓' : '✗';
console.log(`${status} ${step.keyword}${step.text}`);
if (!result.passed && result.error) {
console.error(` Error: ${result.error}`);
}
if (result.duration) {
console.log(` Duration: ${result.duration}ms`);
}
}
// Framework configuration examples
const mochaConfig: WebdriverIO.MochaOpts = {
timeout: 60000,
bail: false,
ui: 'bdd',
grep: '@smoke',
retries: 2,
reporter: 'spec'
};
const jasmineConfig: WebdriverIO.JasmineOpts = {
defaultTimeoutInterval: 60000,
stopOnFailure: false,
random: true,
oneFailurePerSpec: false
};
const cucumberConfig: WebdriverIO.CucumberOpts = {
require: ['./step-definitions/**/*.ts'],
tags: '@smoke and not @skip',
strict: true,
failFast: false,
timeout: 60000,
retry: 1
};Install with Tessl CLI
npx tessl i tessl/npm-wdio--types@9.19.1