-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Description
Feature Request Checklist
- I have read and agree to Mocha's Code of Conduct and Contributing Guidelines
- I have searched for related issues and issues with the
faqlabel, but none matched my issue. - I want to provide a PR to resolve this
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
Labels
Type
Projects
Status