feat: add global test timeout configuration option#33256
Draft
omer-za wants to merge 2 commits intocypress-io:developfrom
Draft
feat: add global test timeout configuration option#33256omer-za wants to merge 2 commits intocypress-io:developfrom
omer-za wants to merge 2 commits intocypress-io:developfrom
Conversation
Add new `testTimeout` configuration option that allows setting a global maximum duration for tests. If a test (including all its hooks) exceeds this duration, it will fail automatically. - Default value is 0 (disabled for backward compatibility) - Can be overridden at any level (config file, describe, it) - Properly cleans up timeout when test completes or is retried This addresses the need for a global test timeout that limits overall test duration, complementing existing command-level timeouts.
|
|
Collaborator
|
When a test exceeds the global timeout, collect and log diagnostic information to help debug what was happening: - Current command being executed (name, args, type, timeout) - Command queue state (total commands, last 20 command names) - Recent logs (last 10 log entries with name, message, state) - Current URL - Registered aliases Diagnostics are: 1. Logged to browser console in a grouped format 2. Attached to the error object as 'diagnostics' property for programmatic access in event handlers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a new
testTimeoutconfiguration option that allows setting a global maximum duration for tests. Unlike existing command-level timeouts (defaultCommandTimeout,responseTimeout, etc.), this option limits the total duration of a test including all its hooks.Problem
Currently, Cypress has no way to enforce a global test timeout. Each individual command has its own timeout, but a test could theoretically run indefinitely if each command completes within its respective timeout. Users have requested the ability to fail tests that exceed a certain total duration.
Solution
Add a new
testTimeoutconfiguration option:0(disabled, for backward compatibility)it('test', { testTimeout: 30000 }, ...)Example Usage
Diagnostics on Timeout
When a test times out, the following diagnostic information is captured and logged to the browser console:
Example console output:
The diagnostics are also attached to the error object as
err.diagnosticsfor programmatic access.Changes
packages/config/src/options.tstestTimeoutconfig option with default0cli/types/cypress.d.tspackages/driver/src/cypress/error_messages.tspackages/driver/src/cypress/runner.tsImplementation Details
wallClockStartedAtis first set)testAfterRun)cy.fail()to properly fail the test and trigger cleanupTesting
Note: This is a proof-of-concept implementation. Additional testing and edge case handling may be needed for production readiness.