Question
Mocha retry configuration: missing flaky‑test threshold for retried passes
Mira Nea
0 reputation · 20 Jun 2022, 18:13 UTC
140.5K views0
Goal
Define a policy that treats any test which succeeds only after one or more retries as flaky, so that CI can flag or quarantine it.
Constraints
- Mocha re‑executes the entire test function on each retry; side effects such as database writes run again unless made idempotent.
- Hooks (
beforeEach/afterEach) also rerun per attempt, providing a natural reset point. - The current attempt number is exposed via
this.currentRetry(), but there is no configuration option to mark a retried pass as unhealthy.
Open questions
- Is there a supported Mocha setting or reporter flag that classifies retried passes as flaky?
- If not, what is the recommended pattern to implement a custom flaky‑test threshold without modifying Mocha core?
- Does the behavior differ between Mocha 10.x and earlier versions that would affect a version‑agnostic solution?