mochajs/mocha
63.5
Adequate · 16 September 2026
13.8k
lines of production code
JavaScript
primary language
1
measurement over time
What this system is
This system is Mocha, a JavaScript test runner that executes tests across Node.js and browser environments using BDD, TDD, and QUnit interfaces. It provides a command-line interface for managing test suites, supporting features like parallel execution via child processes, watch mode, and various reporting formats including GitHub Actions integration. The system handles module loading for both ES modules and CommonJS, manages test hooks and retries, and offers a plugin architecture for extensibility.
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 release also included a rewritten CLI entry point, a dependency overhaul, and the addition of a GitHub Actions reporter. Extensive integration and regression tests were added to validate the new architecture and core behaviors.
2017–2018 — CLI ESM migration and test expansion
13 changes.
The CLI module was rewritten in ESM using Node.js's util.parseArgs, introducing new flags and removing the yargs dependency. Concurrently, the project significantly expanded its test suite, migrating assertions to the Unexpected library and adding comprehensive coverage for browser entry points, configuration loading, and various CLI options.
2019–2025 — Build modernization and test expansion
15 changes.
The project modernized its build infrastructure by migrating scripts to ES modules and replacing Browserify with Rollup. Concurrently, it significantly expanded integration and unit test coverage, adding extensive fixtures for parallel execution, ES module handling, error scenarios, and compiler outputs.
2026 — comprehensive test coverage expansion
5 changes.
This period focused on significantly expanding the test suite by adding extensive integration and unit tests for Mocha's core components, CLI options, and parallel execution infrastructure. The work included establishing browser test infrastructure with Playwright and verifying the correct behavior of runner events, hooks, and reporters across various modes and environments.
Features
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 child processes instead of worker threads
The parallel test runner has been refactored to use the \workerpool\ library to spawn child processes rather than Node.js worker threads. This change introduces a new \BufferedWorkerPool\ and \ParallelBufferedRunner\ that serialize test options and events via IPC, allowing parallel tests to run in isolated processes. This improves stability for parallel runs, particularly when handling circular dependencies in error objects or combining \--parallel\ with \--retries\, and ensures that test files are loaded in a way that is compatible with ESM modules and webpack bundling.
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 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 tests for --allow-uncaught with this.skip(); Added integration tests for ES module loading scenarios; Added integration tests for diff output formatting; Added integration tests for multiple Mocha runs; Added integration tests for the ignore option; Added parallel mode integration test fixtures; Added regression test fixtures for memory leaks, error handling, and suite filtering; 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 CLI options; 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 watchdog.canine.dev from the codebase's own history, inside the signed delivery this page is composed from.
How this codebase got here
Baseline
- First survey — no prior run to compare against. CAI 64.
Lenses
- Code Health 56
- Architecture 90
- Maturity 68
- Readiness 72
- Security 67
Changes since last survey
- 300 commits — 250 feature/other, 50 fixes
By area
- (root) — 136 commits
- .github/workflows — 50 commits
- docs/src — 25 commits
- test/integration — 14 commits
- lib/cli — 13 commits
- lib/reporters — 9 commits
- docs/package-lock.json — 8 commits
- .github/CONTRIBUTING.md — 5 commits
- test/node-unit — 4 commits
- test/unit — 4 commits
- .github/release-please — 3 commits
- docs-next/src — 3 commits
- docs/astro.config.ts — 3 commits
- lib/nodejs — 3 commits
- test/reporters — 3 commits
- docs-next/package-lock.json — 2 commits
- lib/utils.js — 2 commits
- .github/CODE_OF_CONDUCT.md — 1 commit
- .github/DEVELOPMENT.md — 1 commit
- .github/ISSUE_TEMPLATE — 1 commit
Notable commits
- fix: Revert "chore: fix timeout issue with some XUnit tests"
- fix: Revert "fix: begin running tests immediately instead of waiting for w… (#5881)
- fix: build: run npm audit fix (#5695)
- fix: chore: add link from bug template to security explainer (#5782)
- fix: chore: convert node-flags and options to ESM, fix ESLint issue (#5900)
- fix: chore: fix "remove 'waiting for author' " workflow (#6090)
- fix: chore: fix Knip issues (#5919)
- fix: chore: fix RC 1 blog publish time, rename to ...-rc-1 (#6106)
- fix: chore: fix Release Please manifest (#6097)
- fix: chore: fix esm-utils tests when run without coverage (#6160)
- fix: chore: fix format workflow permissions for npm-script.yml (#5903)
- fix: chore: fix owner in auto-add workflow (#6309)
- fix: chore: fix supporters file extension in knip config (#5796)
- fix: chore: fix timeout issue with some XUnit tests
- fix: ci: comment on issues and PRs when their fix is released (#5960)
- fix: fix(ci): fix for bug in Windows/node 26 (#6290)
- fix: fix(deps): update dependency @astrojs/starlight to ^0.39.0 (#5952)
- fix: fix(deps): update dependency chokidar to v5 (#5734)
- fix: fix(deps): update dependency diff to v9 (#5917)
- fix: fix(deps): update dependency find-up to v8 (#5747)
- …and 280 more
Written by watchdog.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 16 September 2026 at a pinned commit. It is not a live figure and does not change until the project is measured again.
- Measured at commit 633480c976dc49d73693148b43983778e2f44f49 — the exact code this score is about.
- Scored under rubric-2026.09.11 — the same rubric and the same method as every other entry in this index.
- Measured by watchdog.canine.dev using codehealth-analyzer preprod-6ffd5c734814.