Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Webdriverio Webdriverio Config Constants

From Leeroopedia
Knowledge Sources
Domains Configuration, Defaults
Last Updated 2026-02-12 00:00 GMT

Overview

Default configuration values, supported hook definitions, supported file extensions, and error messages used as the foundation for WebdriverIO testrunner configuration initialization and validation.

Description

This module exports the core configuration constants that underpin the WebdriverIO testrunner. The DEFAULT_CONFIGS factory function returns a complete WebdriverIO.Config object with sensible defaults for all configuration properties including specs, capabilities, logging, timeouts, framework options, and every lifecycle hook initialized as an empty array. SUPPORTED_HOOKS enumerates all recognized hook names used for configuration validation. SUPPORTED_FILE_EXTENSIONS lists the file extensions that WebdriverIO recognizes for spec and configuration files. NO_NAMED_CONFIG_EXPORT provides the error message shown when a configuration file lacks the expected named export.

Usage

Use DEFAULT_CONFIGS() when you need to obtain a baseline configuration object to merge with user-provided options (as done by defineConfig()). Reference SUPPORTED_HOOKS when validating or iterating over hook definitions in configuration processing. Check SUPPORTED_FILE_EXTENSIONS when resolving or filtering spec files. These constants are consumed internally by the config loader and validator, and are also useful for tooling that generates or manipulates WebdriverIO configurations.

Code Reference

Source Location

Signature

export const DEFAULT_CONFIGS: () => WebdriverIO.Config = () => ({
    specs: [],
    suites: {},
    exclude: [],
    capabilities: [],
    outputDir: undefined,
    logLevel: 'info' as const,
    logLevels: {},
    groupLogsByTestSpec: false,
    excludeDriverLogs: [],
    bail: 0,
    waitforInterval: 100,
    waitforTimeout: 5000,
    framework: 'mocha' as const,
    reporters: [],
    services: [],
    maxInstances: 100,
    maxInstancesPerCapability: 100,
    injectGlobals: true,
    filesToWatch: [],
    connectionRetryTimeout: 120000,
    connectionRetryCount: 3,
    execArgv: [],
    runnerEnv: {},
    runner: 'local' as const,
    shard: { current: 1, total: 1 },
    specFileRetries: 0,
    specFileRetriesDelay: 0,
    specFileRetriesDeferred: false,
    autoAssertOnTestEnd: true,
    reporterSyncInterval: 100,
    reporterSyncTimeout: 5000,
    cucumberFeaturesWithLineNumbers: [],
    // framework defaults
    mochaOpts: { timeout: 10000 },
    jasmineOpts: { defaultTimeoutInterval: 10000 },
    cucumberOpts: { timeout: 10000 },
    // hooks (all initialized as empty arrays)
    onPrepare: [], onWorkerStart: [], onWorkerEnd: [],
    before: [], beforeSession: [], beforeSuite: [],
    beforeHook: [], beforeTest: [], beforeCommand: [],
    afterCommand: [], afterTest: [], afterHook: [],
    afterSuite: [], afterSession: [], after: [],
    onComplete: [], onReload: [],
    beforeAssertion: [], afterAssertion: [],
    // cucumber hooks
    beforeFeature: [], beforeScenario: [], beforeStep: [],
    afterStep: [], afterScenario: [], afterFeature: []
})

export const DEFAULT_MAX_INSTANCES_PER_CAPABILITY_VALUE = 100

export const SUPPORTED_HOOKS: (keyof Services.Hooks)[] = [
    'before', 'beforeSession', 'beforeSuite', 'beforeHook',
    'beforeTest', 'beforeCommand', 'afterCommand', 'afterTest',
    'afterHook', 'afterSuite', 'afterSession', 'after',
    'beforeAssertion', 'afterAssertion',
    'beforeFeature', 'beforeScenario', 'beforeStep',
    'afterStep', 'afterScenario', 'afterFeature',
    'onReload', 'onPrepare', 'onWorkerStart', 'onWorkerEnd', 'onComplete'
]

export const SUPPORTED_FILE_EXTENSIONS = [
    '.js', '.jsx', '.mjs', '.mts', '.es6',
    '.ts', '.tsx', '.feature', '.coffee', '.cjs'
]

export const NO_NAMED_CONFIG_EXPORT = (
    'No named export object called "config" found. ...'
)

Import

import {
    DEFAULT_CONFIGS,
    SUPPORTED_HOOKS,
    SUPPORTED_FILE_EXTENSIONS,
    DEFAULT_MAX_INSTANCES_PER_CAPABILITY_VALUE,
    NO_NAMED_CONFIG_EXPORT
} from '@wdio/config'

I/O Contract

Exported Constants
Name Type Value/Return Description
DEFAULT_CONFIGS () => WebdriverIO.Config Complete config object Factory returning default configuration with all properties set
DEFAULT_MAX_INSTANCES_PER_CAPABILITY_VALUE number 100 Default maximum parallel instances per capability
SUPPORTED_HOOKS (keyof Services.Hooks)[] Array of 23 hook names All supported lifecycle hook names for validation
SUPPORTED_FILE_EXTENSIONS string[] 10 extensions File extensions recognized by spec file resolution
NO_NAMED_CONFIG_EXPORT string Error message Message shown when config file lacks named export
Key Default Values
Property Default Type Notes
logLevel 'info' string Logging verbosity
bail 0 number 0 means run all tests regardless of failures
waitforTimeout 5000 number 5 seconds for waitFor* commands
waitforInterval 100 number 100ms polling interval
framework 'mocha' string Default test framework
maxInstances 100 number Maximum total parallel workers
connectionRetryTimeout 120000 number 2 minutes WebDriver request timeout
connectionRetryCount 3 number Number of request retries
runner 'local' string Default runner type
specFileRetries 0 number No spec file retries by default
mochaOpts.timeout 10000 number 10 second Mocha test timeout

Usage Examples

import {
    DEFAULT_CONFIGS,
    SUPPORTED_HOOKS,
    SUPPORTED_FILE_EXTENSIONS
} from '@wdio/config'

// Get default configuration and merge with user options
const defaults = DEFAULT_CONFIGS()
const userConfig: Partial<WebdriverIO.Config> = {
    specs: ['./test/**/*.spec.ts'],
    maxInstances: 5,
    logLevel: 'warn'
}
const mergedConfig = { ...defaults, ...userConfig }

// Validate that a hook name is supported
function isValidHook(hookName: string): boolean {
    return SUPPORTED_HOOKS.includes(hookName as keyof Services.Hooks)
}

// Filter spec files by supported extensions
function isSupported(filePath: string): boolean {
    return SUPPORTED_FILE_EXTENSIONS.some(ext => filePath.endsWith(ext))
}
const specFiles = ['login.spec.ts', 'data.json', 'checkout.feature']
const validSpecs = specFiles.filter(isSupported)
// Result: ['login.spec.ts', 'checkout.feature']

// Iterate over all hooks in configuration
for (const hookName of SUPPORTED_HOOKS) {
    const hookValue = mergedConfig[hookName]
    if (Array.isArray(hookValue) && hookValue.length > 0) {
        console.log(`Hook "${hookName}" has ${hookValue.length} handler(s)`)
    }
}

// Access specific default values
console.log(`Default framework: ${defaults.framework}`)       // 'mocha'
console.log(`Default max instances: ${defaults.maxInstances}`) // 100
console.log(`Default retry timeout: ${defaults.connectionRetryTimeout}`) // 120000

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment