# Extension points — mochajs/mocha

> Canonical page: https://codevetter.com/unpack/mocha/extension-points

# Extension points — mochajs/mocha

Scanned commit 79db2ee53b863813b97bf2a74cafa1599115c074 (2026-10-01). Generated by codevetter codevetter 1.15.0 on 2026-10-02.

Source inspection; upstream code and tests were not executed.

The strongest extension contracts are interfaces, reporters, and required-module plugins. CLI option metadata centralizes names, types, aliases, and help text. Runner events are the shared observation API across serial and parallel modes. Some worker and loader customization hooks are internal and should be treated with that narrower stability expectation.
- Mocha.ui accepts an interface function, a built-in registry name, or a resolvable module, unwraps a default export, and invokes the binding function with the root suite. — [lib/mocha.cjs#L361-L387](https://github.com/mochajs/mocha/blob/79db2ee53b863813b97bf2a74cafa1599115c074/lib/mocha.cjs#L361-L387) [lib/interfaces/index.js#L1-L11](https://github.com/mochajs/mocha/blob/79db2ee53b863813b97bf2a74cafa1599115c074/lib/interfaces/index.js#L1-L11)
- Interfaces attach to Suite's pre-require event; createCommon supplies suite factories and hook registration, allowing a new DSL to reuse shared only/skip behavior. — [lib/interfaces/bdd.js#L24-L46](https://github.com/mochajs/mocha/blob/79db2ee53b863813b97bf2a74cafa1599115c074/lib/interfaces/bdd.js#L24-L46) [lib/interfaces/common.js#L54-L85](https://github.com/mochajs/mocha/blob/79db2ee53b863813b97bf2a74cafa1599115c074/lib/interfaces/common.js#L54-L85) [lib/interfaces/common.js#L96-L143](https://github.com/mochajs/mocha/blob/79db2ee53b863813b97bf2a74cafa1599115c074/lib/interfaces/common.js#L96-L143)
- Mocha.reporter accepts a constructor, built-in name, package ID, or cwd-relative module, unwraps default exports, and supplies reporterOption/reporterOptions aliases. — [lib/mocha.cjs#L310-L349](https://github.com/mochajs/mocha/blob/79db2ee53b863813b97bf2a74cafa1599115c074/lib/mocha.cjs#L310-L349) [lib/reporters/index.cjs#L5-L36](https://github.com/mochajs/mocha/blob/79db2ee53b863813b97bf2a74cafa1599115c074/lib/reporters/index.cjs#L5-L36)
- Reporter constructors receive runner and options; Mocha invokes an optional reporter.done(failures, callback), while createStatsCollector makes runner.stats available before reporter construction. — [lib/mocha.cjs#L994-L1005](https://github.com/mochajs/mocha/blob/79db2ee53b863813b97bf2a74cafa1599115c074/lib/mocha.cjs#L994-L1005) [lib/mocha.cjs#L1022-L1035](https://github.com/mochajs/mocha/blob/79db2ee53b863813b97bf2a74cafa1599115c074/lib/mocha.cjs#L1022-L1035) [lib/stats-collector.js#L46-L69](https://github.com/mochajs/mocha/blob/79db2ee53b863813b97bf2a74cafa1599115c074/lib/stats-collector.js#L46-L69)
- Required modules can export mochaHooks, mochaGlobalSetup, and mochaGlobalTeardown; hook factories may be asynchronous, and finalization merges four hook lists into rootHooks. — [lib/plugin-loader.js#L25-L74](https://github.com/mochajs/mocha/blob/79db2ee53b863813b97bf2a74cafa1599115c074/lib/plugin-loader.js#L25-L74) [lib/plugin-loader.js#L81-L120](https://github.com/mochajs/mocha/blob/79db2ee53b863813b97bf2a74cafa1599115c074/lib/plugin-loader.js#L81-L120) [lib/cli/run-helpers.cjs#L109-L121](https://github.com/mochajs/mocha/blob/79db2ee53b863813b97bf2a74cafa1599115c074/lib/cli/run-helpers.cjs#L109-L121)
- Internal PluginLoader.create accepts pluginDefs and ignore lists; register enforces unique export names, and each definition can provide validate and async finalize functions. — [lib/plugin-loader.js#L186-L219](https://github.com/mochajs/mocha/blob/79db2ee53b863813b97bf2a74cafa1599115c074/lib/plugin-loader.js#L186-L219) [lib/plugin-loader.js#L228-L269](https://github.com/mochajs/mocha/blob/79db2ee53b863813b97bf2a74cafa1599115c074/lib/plugin-loader.js#L228-L269) [lib/plugin-loader.js#L281-L282](https://github.com/mochajs/mocha/blob/79db2ee53b863813b97bf2a74cafa1599115c074/lib/plugin-loader.js#L281-L282)
- run-option-metadata.cjs centralizes option types, aliases, and descriptions; getRunOptionDefinitions feeds CLI help, and flag/type lookup functions derive from the same tables. — [lib/cli/run-option-metadata.cjs#L15-L66](https://github.com/mochajs/mocha/blob/79db2ee53b863813b97bf2a74cafa1599115c074/lib/cli/run-option-metadata.cjs#L15-L66) [lib/cli/run-option-metadata.cjs#L75-L95](https://github.com/mochajs/mocha/blob/79db2ee53b863813b97bf2a74cafa1599115c074/lib/cli/run-option-metadata.cjs#L75-L95) [lib/cli/run-option-metadata.cjs#L150-L170](https://github.com/mochajs/mocha/blob/79db2ee53b863813b97bf2a74cafa1599115c074/lib/cli/run-option-metadata.cjs#L150-L170) [lib/cli/cli.js#L38-L44](https://github.com/mochajs/mocha/blob/79db2ee53b863813b97bf2a74cafa1599115c074/lib/cli/cli.js#L38-L44)
- loadFilesAsync accepts an esmDecorator; parallel reporters can request partial-object linking, and ParallelBufferedRunner exposes workerReporter for selecting an alternate worker reporter. — [lib/mocha.cjs#L438-L452](https://github.com/mochajs/mocha/blob/79db2ee53b863813b97bf2a74cafa1599115c074/lib/mocha.cjs#L438-L452) [lib/nodejs/parallel-buffered-runner.cjs#L398-L402](https://github.com/mochajs/mocha/blob/79db2ee53b863813b97bf2a74cafa1599115c074/lib/nodejs/parallel-buffered-runner.cjs#L398-L402) [lib/nodejs/parallel-buffered-runner.cjs#L414-L425](https://github.com/mochajs/mocha/blob/79db2ee53b863813b97bf2a74cafa1599115c074/lib/nodejs/parallel-buffered-runner.cjs#L414-L425)

Every claim links to its cited files at the pinned commit. Citations identify source evidence; they do not establish runtime correctness. Independent CodeVetter scan — not reviewed by upstream maintainers.

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
