Skip to content

🚀 Feature: Include Actual Test Duration in Timeout Error Messages #5543

@saranganet

Description

@saranganet

Feature Request Checklist

Overview

Right now, timeout errors look like:

Error: Timeout of 2000ms exceeded.

This message does not tell developers whether the test ran only slightly over (e.g., 2100ms) or was massively slow (e.g., 15000ms).
Both scenarios require different debugging strategies.

Add the actual test runtime to timeout error messages when available, such as:

Error: Timeout of 2000ms exceeded. Test ran for 2450ms.

Suggested Solution

I propose extending the timeout error logic so that the actual duration of the test is included whenever available. This involves:
Tracking the start time of each runnable test.
Passing the computed duration into _timeoutError() when a timeout occurs or when a test completes after the timeout threshold.
Updating the error message format to include something like:
“Test ran for Xms” (only when duration data exists).

Alternatives

-Keeping current behavior: Developers manually instrument slow tests, use custom timers, or rely on external tools, but this adds friction and is not ideal in CI environments.

-Adding a verbose/debug mode: Only include durations when a debug flag is active. This reduces the risk of reporter output changes but makes helpful information harder to discover.

Additional Info

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions