Implementation:Webdriverio Webdriverio ESLint NoPause
| Knowledge Sources | |
|---|---|
| Domains | Linting, Test_Quality |
| Last Updated | 2026-02-12 00:00 GMT |
Overview
ESLint rule that disallows browser.pause() calls in test files to prevent hard-coded wait statements from degrading test reliability.
Description
The no-pause rule is defined as a Rule.RuleModule of type "problem". It leverages the isCommand helper utility to detect calls to pause() on configured browser instances. The rule accepts an optional instances configuration array (defaulting to ["browser"]) to support multiremote setups. When a CallExpression node matches a pause invocation on any configured instance, the rule reports an unexpectedPause error. This discourages the use of arbitrary wait times that make tests flaky and slow.
Usage
Use this rule in shared ESLint configurations to enforce best practices around waiting strategies. Instead of browser.pause(), teams should use WebdriverIO's built-in waitUntil, waitForDisplayed, or other explicit wait commands that are condition-based rather than time-based.
Code Reference
Source Location
- Repository: Webdriverio_Webdriverio
- File: packages/eslint-plugin-wdio/src/rules/no-pause.ts
Signature
const rule: Rule.RuleModule = {
meta: {
type: 'problem',
docs: {
description: 'Disallow browser.pause() in tests',
category: 'Possible Errors',
recommended: false,
},
messages: {
unexpectedPause: 'Unexpected browser.pause() 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-pause'
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 unexpectedPause when pause() is called on a configured browser instance |
Usage Examples
// .eslintrc.js configuration
module.exports = {
plugins: ['wdio'],
rules: {
'wdio/no-pause': 'error'
}
}
// .eslintrc.js - with multiremote instances
module.exports = {
plugins: ['wdio'],
rules: {
'wdio/no-pause': ['error', {
instances: ['browser', 'browserA', 'browserB']
}]
}
}
// Incorrect - will trigger the rule
await browser.pause(5000)
// Correct - use explicit waits instead
await element.waitForDisplayed({ timeout: 5000 })
await browser.waitUntil(async () => await element.isDisplayed(), { timeout: 5000 })