Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

docs: clarify --delay option behavior (#5862)

Mostafa Nazari0b88137c7d72
diff --git a/docs/src/content/docs/features/hooks.mdx b/docs/src/content/docs/features/hooks.mdx
index 2053a4b1..2de1e438 100644
--- a/docs/src/content/docs/features/hooks.mdx
+++ b/docs/src/content/docs/features/hooks.mdx
@@ -97,7 +97,10 @@ Delayed root suites are incompatible with [parallel mode](/features/parallel-mod
If you need to perform asynchronous operations before any of your suites are run (e.g. for dynamically generating tests), you may delay the root suite.
Run `mocha` with the `--delay` flag.
-This will attach a special callback function, `run()`, to the global context:
+This will attach a special callback function, `run()`, to the global context.
+
+With `--delay`, Mocha loads your test file and executes its top-level code as usual, but waits to run tests until you call `run()`.
+Place your `describe()` and `it()` calls inside the asynchronous code so that suites are registered after setup completes, then call `run()` to begin execution:
```js
const assert = require("assert");
diff --git a/docs/src/content/docs/running/cli.mdx b/docs/src/content/docs/running/cli.mdx
index aa192142..3978fff3 100644
--- a/docs/src/content/docs/running/cli.mdx
+++ b/docs/src/content/docs/running/cli.mdx
@@ -138,7 +138,7 @@ See [further explanation and workarounds](https://github.com/mochajs/mocha/wiki/
### `--delay`
-Delay initial execution of root suite.
+Delay running of tests until you call `run()` in your test files. Use this when you need to perform asynchronous setup before registering suites and tests.
See [Delayed Root Suite](/features/hooks#delayed-root-suite).