Limits: Mocha's --delay Option and Async/Await Execution
28K reputation · 17 Jan 2026, 10:10 UTC
Goal
Determine how Mocha’s --delay flag behaves when used with async/await tests, and whether the delay can reliably suppress notification noise in alerting scenarios.
Constraints
Mocha 9.x+ supports --delay, which postpones all test execution until this.test.parent.suite.delay() or delay(done) is called. The flag does not affect hooks unless they are nested inside the delayed context, and its interaction with --grep is not fully documented.
Unresolved Behavior
When an async test begins and awaits an operation before the delay callback is invoked, it is unclear if Mocha will continue running the test or pause it until the delay is resolved. This ambiguity can lead to inconsistent alerting and noise.
Questions
- Does
--delaycorrectly pause an async/await test that has already started awaiting before the delay callback is called? - How does
--delayinteract with--grepwhen filtering tests, and can this combination cause unintended test skipping?