Skip to content

Timeouts

CodeceptJS provides multiple timeout configurations to control test execution time at different levels.

CodeceptJS timeout levels from narrowest to widest: Helper Timeouts (per browser action, in milliseconds), Step Timeout (step.timeout on a single step, in seconds), Scenario Timeout (cap the whole test), Feature Timeout (cap every test in a feature), and Global Timeout (config default for every test, refinable by grep). All test-level timeouts are measured in seconds. Timeouts — cap a single step, a test, a feature, or everything · test levels are in seconds Per action · milliseconds Helper Timeouts — how long each browser action may take helpers: { Playwright: { timeout: 5000, getPageTimeout: 30000 } } One step Step Timeout — cap a single step in a test I.click('Slow Button', step.timeout(30)) One test Scenario Timeout — cap the whole test Scenario('quick test', { timeout: 5 }, ...) Feature suite Feature Timeout — cap every test in a feature Feature('Slow Operations', { timeout: 60 }) All tests Global Timeout — default for every test · refine with grep export const config = { timeout: [10, { grep: '@slow', Feature: 60 }] }

Set timeout for individual steps using step.timeout():

import step from 'codeceptjs/steps'
Scenario('test with step timeouts', ({ I }) => {
I.amOnPage('/')
I.click('Slow Button', step.timeout(30))
I.fillField('Email', 'user@example.com', step.timeout(10))
})

Override timeout for specific scenarios:

Scenario('quick test', { timeout: 5 }, ({ I }) => {
I.amOnPage('/')
})
Scenario('slow test', { timeout: 120 }, ({ I }) => {
I.amOnPage('/dashboard')
})

Set timeout for all scenarios in a feature:

Feature('Slow Operations', { timeout: 60 })
Scenario('first test', ({ I }) => {
// has 60 second timeout
})
Scenario('second test', ({ I }) => {
// has 60 second timeout
})

Set default timeout for all tests in codecept.conf.js:

export const config = {
timeout: 10 // 10 seconds for all tests
}

Use advanced configuration with grep patterns for conditional timeouts:

export const config = {
timeout: [
10, // default timeout
{
grep: '@slow',
Feature: 60 // 60 seconds for features tagged @slow
},
{
grep: /critical/,
Scenario: 30 // 30 seconds for scenarios matching pattern
}
]
}

Each helper (Playwright, Puppeteer, WebDriver, Appium, REST) has its own timeout settings for browser actions, API requests, and element interactions. These are configured separately from test timeouts and are measured in milliseconds.

Refer to helper-specific documentation for timeout configuration:

Automatically apply timeouts to all steps:

plugins: {
stepTimeout: {
enabled: true,
timeout: 150, // default step timeout in seconds
overrideStepLimits: false, // override step.timeout() if true
noTimeoutSteps: [
'amOnPage',
'wait*' // wildcard patterns supported
],
customTimeoutSteps: [
['slowAction*', 30], // 30 seconds for matching steps
[/critical.*/, 60] // regex patterns supported
]
}
}

When multiple timeouts are configured, CodeceptJS applies them in priority order:

  1. stepTimeoutHard — plugin with overrideStepLimits: true
  2. codeLimitTimestep.timeout()
  3. stepTimeoutSoft — plugin with overrideStepLimits: false
  4. testOrSuite — global test/suite timeout

Higher priority timeouts override lower priority ones.

Disable all timeouts for debugging:

Terminal window
npx codeceptjs run --no-timeouts
codecept.conf.js
export const config = {
timeout: [
10,
{ grep: '@slow', Feature: 60 },
{ grep: '@critical', Scenario: 30 }
],
helpers: {
Playwright: {
timeout: 5000,
waitForTimeout: 1000,
getPageTimeout: 30000
}
},
plugins: {
stepTimeout: {
enabled: true,
timeout: 150,
noTimeoutSteps: ['amOnPage', 'wait*'],
customTimeoutSteps: [
['slowAction*', 30]
]
}
}
}
// test file
import step from 'codeceptjs/steps'
Feature('User Management @slow', { timeout: 60 })
Scenario('create user', { timeout: 20 }, ({ I }) => {
I.amOnPage('/users')
I.click('Create', step.timeout(10))
I.fillField('Name', 'John', step.timeout(5).retry(2))
})
  • Global, Feature, Scenario, Step, stepTimeout plugin — seconds
  • Helper timeouts — milliseconds