Implementation:Webdriverio Webdriverio ESLint NoDebug
| Knowledge Sources | |
|---|---|
| Domains | Linting, Test_Quality |
| Last Updated | 2026-02-12 00:00 GMT |
Overview
ESLint rule that disallows browser.debug() calls in test files to prevent debugging statements from being committed to the codebase.
Description
The no-debug rule is defined as a Rule.RuleModule of type "problem". It uses the isCommand helper to detect calls to debug() on configured browser instances. The rule accepts an optional instances configuration array (defaulting to ["browser"]) allowing teams to specify additional browser variable names (e.g., multiremote instances). When a CallExpression node matches a debug call on any configured instance, the rule reports an unexpectedDebug error. This prevents browser.debug() breakpoints from accidentally reaching production test suites.
Usage
Use this rule in CI/CD pipelines and shared ESLint configurations to ensure that interactive debug() calls used during local development are not left in committed test code. Configure the instances option when using multiremote setups with custom browser variable names.
Code Reference
Source Location
- Repository: Webdriverio_Webdriverio
- File: packages/eslint-plugin-wdio/src/rules/no-debug.ts
Signature
const rule: Rule.RuleModule = {
meta: {
type: 'problem',
docs: {
description: 'Disallow browser.debug() in tests',
category: 'Possible Errors',
recommended: false,
},
messages: {
unexpectedDebug: 'Unexpected browser.debug() not allowed'
},
hasSuggestions: true,
schema: [{
type: 'object',
properties: {
instances: {
type: 'array',
items: { type: 'string' },
description: 'List of browser instances to check (default: ["browser"])',
default: ['browser'],
},
},
additionalProperties: false,
}],
},
create: function (context: Rule.RuleContext): Rule.RuleListener
}
export default rule
Import
import rule from '@wdio/eslint-plugin-wdio/src/rules/no-debug'
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| context | Rule.RuleContext | Yes | ESLint rule context providing AST traversal and reporting API |
| options.instances | string[] | No | List of browser instance variable names to check (default: ["browser"]) |
Outputs
| Name | Type | Description |
|---|---|---|
| Rule.RuleListener | object | Listener object with a CallExpression visitor that reports unexpectedDebug when debug() is called on a configured browser instance |
Usage Examples
// .eslintrc.js - basic configuration
module.exports = {
plugins: ['wdio'],
rules: {
'wdio/no-debug': 'error'
}
}
// .eslintrc.js - with multiremote instances
module.exports = {
plugins: ['wdio'],
rules: {
'wdio/no-debug': ['error', {
instances: ['browser', 'myChromeBrowser', 'myFirefoxBrowser']
}]
}
}
// Incorrect - will trigger the rule
await browser.debug()
// Correct - debug() removed before committing
// (no replacement; simply remove the call)