Directory Compare FCRS-1.0 /llms.txt
← Back to Directory

Mocha

$ mocha Foundation Low Risk
OpenJS Foundation · Code & DevOps · MIT · macos / linux / windows

mocha is a long-standing Node.js test runner supporting BDD/TDD interfaces, regex test filtering via --grep, and structured output via --reporter json. It also includes --dry-run to validate test discovery and --no-colors for clean logs.

FCRS-1.0 Score
82 /100
Good
Medium Confidence
Zero-Friction Install
npm install -D mocha
CLI vs MCP Decision CLI Only

Local Node.js test runner executing workspace test specs directly via npx mocha.

Agent-Readiness Checklist

✓ JSON Output
✓ Field Filtering
✓ Non-Interactive
✓ Dry-Run
— Read-Only Mode
✓ NO_COLOR Clean
✓ Self-Describing
— Official SKILL.md

Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.

FCRS-1.0 6-Dimension Breakdown

Agent-Readiness 21 / 25

Built-in --reporter json, --grep filtering, --dry-run, and --no-colors give agents clean structured control.

  • --reporter json and --dry-run supported natively
  • --exit prevents hangs from unclosed handles
Trust & Safety 20 / 25

Zero credentials and local execution; --dry-run verifies test loading without running test bodies (though top-level module imports execute).

  • Supports --dry-run for suite inspection
Setup & Portability 13 / 15

Installs cleanly via npm or npx on macOS, Linux, and Windows wherever Node.js is available.

  • Lightweight npm package with minimal dependencies
Utility & Efficiency 12 / 15

Fast, composable test runner, though unlike Jest it relies on external assertion (chai) and coverage (c8) tools.

  • Modular design paired with c8 or nyc for coverage
Maintenance & Lineage 8 / 10

OpenJS Foundation project (mochajs/mocha) with MIT license and stable release cadence.

  • OpenJS Foundation hosted repository
Docs & Verifiability 8 / 10

Clear CLI reference on mochajs.org and readable --help output.

  • Complete CLI documentation on mochajs.org

Security, Auth & Guardrails

Auth Modes
No Auth
Credential Storage

No credentials required; executes local JavaScript tests under Node.js.

Side Effects
Read-Only Local Write
Cost & Quotas

MIT open-source OpenJS Foundation project; free.

Copyable Guardrail for CLAUDE.md / AGENTS.md
# Mocha Agent Rules
- Always pass `--reporter json --no-colors` and avoid `--watch` in headless sessions.
- Use `--dry-run` first to verify test file loading and suite names.
- Pass `--exit` if tested code leaves open timers or sockets that would hang process termination.

Agent-Ready Command Recipes

Safe Read-Only Queries

Dry-run test discovery without executing specs
npx mocha --dry-run --reporter json --no-colors

Reports discovered suites and tests in JSON without running test bodies or hooks.

Run filtered tests with JSON reporter
npx mocha --reporter json --no-colors --grep "auth" --exit

Runs only tests matching auth and prints structured JSON results while forcing clean exit.

Strengths for Agents

  • + --reporter json + --dry-run + --grep allow targeted discovery and execution.
  • + --exit mitigates common Node.js event-loop hangs in automated CI runs.

Caveats & Pitfalls

  • ! Does not include built-in assertions or coverage; projects typically pair it with chai and c8.
  • ! Test console.log output goes to stdout and can corrupt --reporter json unless redirected via --reporter-options output=....

Tested Agent Hosts

Claude Code Codex CLI Gemini CLI