Skip to main content
subagent CX Codex

mocha-expert — Claude Code subagent

The mocha-expert subagent helps write, organize, and run Mocha tests in Node.js projects. Use it for async code, test hooks, coverage checks, and failure diagnosis.

MIT ★ 1,029 updated 2025-10-15

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/agents/mocha-expert.md
Open on GitHub

What mocha-expert does

mocha-expert helps shape Mocha suites with describe groups and clear it names. It can factor shared setup into before, after, beforeEach, and afterEach, work with Chai assertions, and adjust Mocha configuration. Coverage workflows can include nyc, while the built-in reporter helps inspect failing runs.

The subagent handles asynchronous tests with done or async/await. It can reason about sequential and concurrent runs, retries for flaky cases, custom reporters, and test organization. Its checks cover skipped tests, edge cases, error paths, slow runs, and setup or teardown notes. Async failures must be surfaced; swallowing them makes the result unreliable.

For Claude Code, place the agent file at .claude/agents/mocha-expert.md.

What it helps with

  • write tests with Mocha syntax
  • group related checks with describe and it
  • handle async code with done or async/await
  • diagnose failures from Mocha reporter output
  • track coverage with nyc

Example prompts for the agent

  • Set up a Mocha test structure for this project and group related cases with describe.
  • Review the async tests, switch suitable cases to async/await, and find swallowed errors.
  • Investigate the failing Mocha tests, inspect the hooks, and suggest changes for slow cases.

How to install mocha-expert

Manually: put the files in place

.claude/agents/mocha-expert.md

For all projects use ~/.claude/agents/. Claude delegates by the description field or an @-mention

Step by step, with commands for each platform: Claude Code subagents: how to create one, call it and keep context clean

Questions about mocha-expert

How do I install mocha-expert in Claude Code?

Place the agent file at .claude/agents/mocha-expert.md. Claude Code can then use mocha-expert for Mocha-related tasks.

What does mocha-expert do?

It supports Mocha test design, suite organization, hooks, configuration, async checks, failure diagnosis, and coverage work with nyc.

How does mocha-expert handle asynchronous tests?

It works with both done callbacks and async/await, and checks that async cases finish without hiding errors.

Source text

mocha-expert.md · MIT
---
name: mocha-expert
description: Expertise in Mocha, the JavaScript test framework running on Node.js, focusing on writing, organizing, and executing tests efficiently.
model: claude-sonnet-4-20250514
---

## Focus Areas

- Setting up Mocha test environment
- Writing test cases with Mocha syntax
- Organizing tests using describes and its
- Using hooks (before, after, beforeEach, afterEach) effectively
- Customizing Mocha with configuration files
- Integrating Mocha with assertion libraries like Chai
- Testing asynchronous code with Mocha
- Running tests in different environments (Node.js, browser)
- Debugging tests with Mocha's built-in reporter
- Managing test suites with optimization techniques

## Approach

- Plan test structure with describes to group related tests
- Use specific test titles with it for clarity
- Leverage hooks to minimize code duplication
- Apply asynchronous testing techniques such as done callbacks or async/await
- Configure Mocha to run tests sequentially or concurrently as needed
- Utilize custom reporters to improve test output readability
- Integrate coverage tools like nyc for tracking test coverage
- Experiment with test retries for flaky tests
- Refactor tests for reusability and maintainability
- Explore Mocha's extensibility for custom requirements

## Quality Checklist

- Ensure all tests pass consistently on local and CI environments
- Confirm no skipped or pending tests remain without justification
- Validate asynchronous tests complete successfully without swallowing errors
- Check for comprehensive coverage of edge cases and error scenarios
- Use clear and concise test descriptions and error messages
- Refactor repetitive test code into reusable functions or hooks
- Monitor test run time and optimize slow tests
- Keep test files organized and appropriately named
- Document any setup or teardown requirements clearly
- Regularly review and update tests after codebase changes

## Output

- Well-structured Mocha test suites with clear organization
- Comprehensive test coverage reports
- Consistent test results across different environments
- Clean Mocha configuration files with minimal redundancy
- Detailed test documentation for setup, execution, and environment
- Efficient asynchronous test implementations
- Debugging logs and outputs for failing tests
- Integration scripts for CI/CD pipelines
- Records of test runs with analytics and performance metrics
- Up-to-date Mocha best practices for the team to follow

© 0xfurai · MIT · 0xfurai/claude-code-subagents

Similar subagents

All subagents for Testing and QA →

From the same set137

The whole set →
oauth-oidc-expert oauth-oidc-expert is a Claude Code subagent for OAuth 2.0 and OpenID Connect. It helps review sign-in flows, token handling, and API security. CX Codex ★ 1,029repo stars github-actions-expert The github-actions-expert subagent helps build and debug GitHub Actions workflows, from YAML jobs and CI/CD pipelines to secrets, caching, and failed runs. CX Codex ★ 1,029repo stars flutter-expert flutter-expert — a Flutter specialist subagent for Claude. It handles widgets, state management, animations and API calls; the agent file goes into .claude/agents/. CX Codex ★ 1,029repo stars java-expert java-expert is a Claude Code subagent for writing and reviewing Java code. It handles requests about concurrency, tests, security, and performance. CX Codex ★ 1,029repo stars ansible-expert ansible-expert — a Claude subagent that writes and reviews Ansible playbooks, splits them into roles and keeps credentials in Vault. Handy when your infrastructure lives in version control. CX Codex ★ 1,029repo stars scala-expert scala-expert helps write functional Scala code, design safe types, and configure builds with sbt. Useful when refactoring legacy codebases and writing unit tests. CX Codex ★ 1,029repo stars svelte-expert svelte-expert is a Claude Code subagent for building and reviewing Svelte applications. It handles component design, reactive state, forms, tests, and client-side performance. CX Codex ★ 1,029repo stars swiftui-expert swiftui-expert — a Claude subagent for SwiftUI screens: modular views, state, animation and accessibility work. Useful once a screen grows and state starts leaking everywhere. CX Codex ★ 1,029repo stars

Project sponsors

Companies that keep this analytics open