docs-next/src/content/docs/explainers/run-cycle-overview.mdx
The following is a mid-level outline of Mocha’s "flow of execution" when run in Node.js; the "less important" details have been omitted.
In a browser, test files are loaded by <script> tags, and calling mocha.run() begins at step 9 below.
mochanode executable are found:
node in a child process, executing itself with these flags--require
--require'd module--require or otherwise.js, .mjs or .cjs in the test directory (but not its children), relative to the current working directoryglobal context (this is how, e.g., describe() ends up as a global in a test file)
--require'd modulesspec by default)