mochajs/mocha
59.8
Adequate · 15 November 2026
13.6k
lines of production code
JavaScript
primary language
4
measurements over time
What this system is
This system is Mocha, a JavaScript test framework that executes unit, integration, and browser tests across Node.js and browser environments. It supports multiple test interfaces (BDD, TDD, QUnit) and features parallel execution via worker processes, comprehensive reporting, and extensibility through plugins and custom reporters. The codebase has been modernized to ES modules, requiring Node.js 20+, and includes robust tooling for configuration, debugging, and CI integration.
How it got here
2011–2016 — ESM migration and v12 overhaul
16 changes.
The project underwent a comprehensive migration to ES modules, updating the core library, interfaces, and reporters while raising the minimum Node.js version to 20+. This v12 overhaul included a rewritten CLI entry point, a new plugin system, and extensive integration tests to validate the new architecture and dependency updates.
2017–2019 — ESM migration and test expansion
17 changes.
The project modernized its core infrastructure by rewriting the CLI and build scripts in ESM, replacing Browserify with Rollup, and switching the assertion library to Unexpected. This period focused heavily on comprehensive test coverage, adding extensive integration and unit tests for the new CLI options, configuration formats, and browser entry points.
2020–2026 — Parallel execution and test coverage expansion
20 changes.
This period focused on refactoring the parallel test runner to use dedicated worker processes with unique IDs and implementing a buffered reporter for coordinated output. Concurrently, extensive integration and unit tests were added to verify core features, including ES module support, CLI options, root hooks, and error handling scenarios.
Features
Add internal parallel-buffered reporter for worker processes
A new \ParallelBuffered\ reporter has been added to handle test output within worker processes during parallel execution. Instead of writing directly to standard output, this reporter buffers test events (such as suite and test lifecycle events) in memory and passes them to the main process via a callback upon completion, enabling coordinated reporting across multiple workers.
lib/nodejs/reporters · high confidence
Migrate reporters to ES modules and add GitHub Actions reporter
The reporter implementations in lib/reporters have been converted from CommonJS to ES modules, updating the module system for base and all bundled reporters (Dot, Doc, TAP, JSON, HTML, List, Min, Nyan, XUnit, Markdown, Progress, Landing, JSONStream). A new built-in GitHub Actions reporter has been added to provide error annotations and job summaries in CI environments. The reporter index has been updated to export the new module format, and the legacy CommonJS index file has been removed.
lib/reporters · high confidence
New browser entry point with HTML5 template and utility modules
The lib/browser location now provides a standardized HTML5 template (template.html) that initializes Mocha in BDD mode and loads the test runner, alongside new utility modules: highlight-tags.js for syntax-highlighting code blocks in the UI and parse-query.js for parsing URL query parameters. This establishes the core browser-side entry point and supporting logic for the Mocha HTML reporter environment.
lib/browser · high confidence
Architecture
Mocha core library refactored to ES modules with new error and plugin systems
The Mocha core library has been migrated to ES modules, replacing the previous CommonJS structure with new files such as lib/context.js, lib/hook.js, lib/runnable.js, and lib/runner.js. This change introduces a new error-handling system via lib/error-constants.js and lib/errors.js, providing structured error codes for better debugging. Additionally, a plugin loader (lib/plugin-loader.js) has been added to support root hooks and global fixtures, enhancing extensibility. The refactoring also includes updates to utility functions and type definitions, ensuring compatibility with modern JavaScript standards while maintaining backward compatibility through the lib/mocha.cjs entry point.
lib · high confidence
Behavioural changes
CLI rewritten in ESM with Node.js util.parseArgs
The CLI module has been converted to ESM and now uses Node.js's built-in util.parseArgs for option parsing, replacing the previous yargs-based implementation. This change introduces the new --clear-screen option for watch mode, adds support for the --node-option flag to pass Node/V8 flags, and prefixes the --interfaces and --reporters listing options with 'list-'. The CLI also now supports multipart file extensions (e.g., .test.js) and allows FIFOs as test files.
lib/cli · high confidence
Migrate core test interfaces to ESM and introduce shared common logic
The BDD, TDD, QUnit, and Exports interfaces have been converted from CommonJS to ES modules, updating imports and exports to use the modern module system. A new \lib/interfaces/common.js\ module has been introduced to centralize shared functionality—such as suite creation, test handling, and hook registration—reducing duplication across the interface implementations. This refactoring ensures consistent behavior for features like \.only\, \.skip\, and pending states while aligning the codebase with the project's ESM migration.
lib/interfaces · high confidence
Parallel test execution now uses dedicated worker processes with unique IDs
The parallel test runner has been refactored to use a buffered worker pool that spawns child processes (via the \workerpool\ library) instead of worker threads. Each worker process is now assigned a unique \MOCHA\_WORKER\_ID\ environment variable, enabling better resource tracking and isolation. This change introduces new internal modules (\buffered-worker-pool\, \parallel-buffered-runner\, \serializer\, \worker-core\) to handle IPC serialization and deserialization of test events and errors, ensuring that complex objects and circular dependencies are correctly transmitted between the main process and workers.
lib/nodejs · high confidence
Refactor build scripts to ESM and replace Browserify with Rollup
The project's build tooling has been modernized by replacing Browserify with Rollup and Babel, including a new custom Rollup plugin (pick-from-package-json.js) to optimize bundle sizes by selectively importing package.json fields. Internal scripts have been migrated to ES modules (e.g., linkify-changelog.js), and the changelog linking script has been fixed to preserve fenced code blocks during processing. Additionally, the authors update script has been updated to support modern Git author metadata formats.
scripts · high confidence
Repository configuration and tooling overhaul for v12
This release introduces a comprehensive set of configuration files and documentation to support the v12 architecture. A \.browserslistrc\ file is added to define supported browser versions (Node \>= 14, last 2 versions of major browsers), replacing ad-hoc browser support logic. The project now uses \.knip.jsonc\ for dependency validation, \.nycrc\ for code coverage configuration, and \.mocharc.yml\ for default test runner settings (including BDD UI and timeout). The build system is standardized with \.prettierignore\ and a \.wallaby.cjs\ configuration for IDE integration. Additionally, \AGENTS.md\ provides a new playbook for AI agents and contributors, detailing command runbooks, environment prerequisites (Node 20/22), and validation steps, while \AUTHORS\ and \CHANGELOG.md\ are updated to reflect the project's history and v12.0.1 fixes.
(repo-wide) · high confidence
Rewritten CLI entry point with Node.js child process spawning
The \bin/mocha\ wrapper script has been replaced by a new \bin/mocha.js\ implementation that delegates execution to the internal CLI module (\lib/cli/cli.js\) via a spawned Node.js child process. This change enables proper handling of Node-specific flags (such as \--inspect\, \--inspect-brk\, and \--node-option\) by separating them from Mocha-specific options before spawning the child process. It also introduces signal forwarding (SIGINT/SIGTERM) to ensure clean termination of the runner and supports POSIX exit codes for fatal signals, while removing the previous in-process execution model that used the \commander\ library directly.
bin · high confidence
Test coverage
Add JS API test runner entry point; Added ESM browser tests and updated test setup; Added ESM compiler tests for standard and top-level-await modules; Added browser test infrastructure and integration tests for global fixtures and root hooks; Added comprehensive test suites for all built-in reporters; Added integration and unit tests for runner event ordering and parallel buffering; Added integration test fixtures for CLI options; Added integration test fixtures for JavaScript and CoffeeScript extensions; Added integration test fixtures for Mocha core behaviors; Added integration test fixtures for globbing; Added integration test fixtures for hook error scenarios; Added integration test fixtures for parallel execution options; Added integration test fixtures for pending and skip behaviors; Added integration test fixtures for root hooks; Added integration test fixtures for the --dry-run option; Added integration test fixtures for uncaught exception and rejection handling; Added integration test fixtures for watch mode scenarios; Added integration tests for --allow-uncaught with this.skip(); Added integration tests for CLI options; Added integration tests for ES module loading scenarios; Added integration tests for Node.js --import=tsx flag and module resolution edge cases; Added integration tests for diff output formatting; Added integration tests for multiple Mocha runs; Added integration tests for the ignore option; Added regression test fixtures for memory leaks, error handling, and suite filtering; Added repro folder for issue reproduction; Added test coverage for BDD, TDD, and Qunit test interfaces; Added test fixtures for Mocha configuration file formats; Added test fixtures for custom ESM and CJS loaders; Added test fixtures for error handling scenarios; Added test fixtures for forbid-pending option scenarios; Added test fixtures for invalid module scenarios; Added test fixtures for retry behavior and hook execution; Added test fixtures for suite callback validation; Added tests for CJS output from ESM source files; Added tests for module require ordering; Added tests for the \it.only\/\test.only\ isolation behavior; Added unit tests for CLI argument parsing, configuration loading, and flag handling; Added unit tests for Mocha core components and reporters; Added unit tests for Node.js parallel execution and utility modules; Expanded integration test coverage for Mocha core features; Mocha tests migrate to Unexpected assertion library.
Dependencies
Mocha 12.0.1: ESM migration, Node 20+ requirement, and dependency overhaul
Mocha has been upgraded to version 12.0.1, shifting the package type to ESM ("type": "module") and raising the minimum supported Node.js version to ^20.19.0 or \>=22.12.0. This release replaces several core dependencies with newer major versions to modernize the codebase: \chokidar\ is updated to v5, \diff\ to v9, \glob\ to v13, \js-yaml\ to v5, \minimatch\ to v10, and \workerpool\ to v10. The CLI entry point has been moved to \bin/mocha.js\, and the \commander\ dependency has been removed in favor of Node.js built-in argument parsing. Development tooling has also been updated, including \eslint\ to v10, \@playwright/test\ to v1.60, and \rollup\ to v4.52.
(dependencies) · high confidence
Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Score
- CAI 60 → 60 (-0.2)
- Rubric changed (rubric-2026.10.5 → rubric-2026.11.4) — scores are not directly comparable.
Lenses
- Code Health 50 → 49 (-1.0)
- Architecture 87 → 90 (+2.9)
- Maturity 68 → 68 (+0.0)
- Readiness 69 → 62 (-6.8)
- Security 72 → 76 (+3.8)
- Accessibility 65 → 80 (+14.6)
- Performance 85 → 100 (+15.0)
Resolved (6)
- High secret: WD-SECRET-0005 (package-lock.json)
- No ADRs found
- Off-boarding risk: anonymized user #1
- Rotate the exposed credentials — git history can't be un-committed
- Secret: aws-access-token (.travis.yml)
- merge-coverage.parseReport (cognitive 23) (scripts/merge-coverage.js)
New (28)
- AWS access key ID with no secret key beside it (.travis.yml)
- Banned license: @img/sharp-libvips-darwin-arm64 (docs/package-lock.json)
- Banned license: @img/sharp-libvips-darwin-x64 (docs/package-lock.json)
- Banned license: @img/sharp-libvips-linux-arm (docs/package-lock.json)
- Banned license: @img/sharp-libvips-linux-arm64 (docs/package-lock.json)
- Banned license: @img/sharp-libvips-linux-ppc64 (docs/package-lock.json)
- Banned license: @img/sharp-libvips-linux-riscv64 (docs/package-lock.json)
- Banned license: @img/sharp-libvips-linux-s390x (docs/package-lock.json)
- Banned license: @img/sharp-libvips-linux-x64 (docs/package-lock.json)
- Banned license: @img/sharp-libvips-linuxmusl-arm64 (docs/package-lock.json)
- Banned license: @img/sharp-libvips-linuxmusl-x64 (docs/package-lock.json)
- Banned license: @img/sharp-wasm32 (docs/package-lock.json)
- Banned license: @img/sharp-win32-arm64 (docs/package-lock.json)
- Banned license: @img/sharp-win32-ia32 (docs/package-lock.json)
- Banned license: @img/sharp-win32-x64 (docs/package-lock.json)
- Medium CVE: [GHSA redacted] (package-lock.json)
- Medium CVE: [GHSA redacted] (package-lock.json)
- Medium CVE: [GHSA redacted] (package-lock.json)
- No ADRs found (package.json)
- Off-boarding risk: anonymized user #1
- …and 8 more
Written by cca.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
Survey your own repository
mochajs/mocha was measured the same way every project in this corpus was: the same rubric, at a pinned commit, with the result published in full. Point a surveyor at a repository you know and see whether you agree with it.
About this page
- The score is its most recent published measurement, taken on 15 November 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit 5b5afa7b12e3f76f4e0c6afa12e960c0b378358c — the exact code this score is about.
- Scored under rubric-2026.11.4 — the same rubric and the same method as every other entry in this index.
- Measured by Canine Code Analyzer (cca.canine.dev) using cca measure-2026.11.65+preprod-3c33c1882dc1.