mocha-to-jest-migration
Use when a JavaScript or TypeScript suite still depends on Mocha, Chai, or Sinon and needs an incremental Jest migration.
Skill by matt-riley
Chalk Labs
Need help deploying mocha-to-jest-migration?
Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/matt-riley-mocha-to-jest-migration
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: testing
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md and code. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
- Runs as
- Node.js package
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/mocha-to-jest-migration
What's inside
- Skill name
mocha-to-jest-migration- Description
- Use when a JavaScript or TypeScript suite still depends on Mocha, Chai, or Sinon and needs an incremental Jest migration.
- License
- GPL-3.0
- Metadata
- kind: task · version: 1.0.0 · audience: general-coding-agent · category: migrations · maturity: draft
- Instructions
- 144 lines in SKILL.md · view on GitHub
Before installing
- Ships executable scripts
Files (13)
- .skill-eval.yaml
- SKILL.md
- evals.json · evals/
- mixed-patterns.spec.js · evals/fixtures/
- mock-lifecycle.spec.js · evals/fixtures/
- proxyquire-module.spec.js · evals/fixtures/
- sinon-args.spec.js · evals/fixtures/
- sinon-sandbox.spec.js · evals/fixtures/
- sinon-stubs.spec.js · evals/fixtures/
- sinon-timers.spec.js · evals/fixtures/
- trigger-queries.json · evals/
- assertion-mapping.md · references/
- mock-mapping.md · references/
SKILL.md (first lines)
# Mocha to Jest migration
## Use this skill when
- The suite still uses Mocha, Chai, or Sinon and needs a staged migration to Jest.
- You find `describe`/`it` tests using Chai assertions or Sinon stubs that need Jest equivalents.
- The work includes runner config, setup files, fake timers, spies, or snapshots.
## Do not use this skill when
- The test suite already uses Jest — the task is not a migration.
- The ask is to add new tests to an existing Mocha suite without converting it.
## Inputs to gather
**Required before editing**
- The existing Mocha, Chai, and Sinon versions and test bootstrap configuration.
- The repository's current or planned Jest configuration and conventions.
**Helpful if present**
- Any test utilities, global setup, environment assumptions, or module mocking patterns.
- The subset of tests to migrate first and the commands used to run them.
**Only investigate if encountered**
- Non-standard Chai plugins (e.g., `chai-as-promised`, `chai-http`) that need separate handling.
## First move
Inventory what needs to migrate before touching any test files:
```sh
grep -r "require('chai')\|from 'chai'\|require('sinon')\|from 'sinon'" --include="*.ts" --include="*.js" -l
grep -r "require('mocha')\|\.mocharc" --include="*.ts" --include="*.js" --include="*.json" -l
```
Then convert a **single small representative file** first, run it under Jest, and confirm the project's Jest setup works before migrating more files.
Consult [`references/assertion-mapping.md`](references/assertion-mapping.md) and [`references/mock-mapping.md`](references/mock-mapping.md) before rewriting patterns.
## Workflow
1. Identify all Mocha, Chai, and Sinon patterns in use.
2. Convert a small representative file first and verify the project's Jest setup.
3. Replace assertion styles with idiomatic Jest expectations using the assertion mapping reference.
4. Replace mocks, spies, and stubs with Jest equivalents using the mock mapping reference.
5. Convert shared setup and teardown patterns carefully (`before`/`after` → `beforeAll`/`afterAll`, `beforeEach`/`afterEach` stay the same).
6. Update test utilities, config, or setup files only where required for parity.
7. Migrate incrementally and run the relevant tests after each batch.
## Worked migration slice
Use this as the shape for one end-to-end file before scaling out:
```js
// Mocha + Chai + Sinon
describe("retries", () => {
let clock;
beforeEach(() => {
clock = sinon.useFakeTimers();
});
afterEach(() => {
clock.restore();
sinon.restore();
});
it("waits and retries once", async () => {
const request = sinon.stub(api, "request").rejects(new Error("nope"));
const retry = sinon.stub(api, "retry").resolves({ ok: true });
const run = service.run();
await clock.tickAsync(1000);
await run;
expect(request.calledOnce).to.equal(true);
expect(retry.calledOnce).to.equal(true);
expect(retry.firstCall.args[0]).to.deep.equal({ delay: 1000 });
});
});
```
```js
// Jest
describe("retries", () => {
beforeEach(() => {
jest.useFakeTimers();
jest.spyOn(api, "request").mockRejectedValue(new Error("nope"));
jest.spyOn(api, "retry").mockResolvedValue({ ok: true });
});
afterEach(() => {
jest.useRealTimers();
jest.restoreAllMocks();
});
it("waits and retries once", async () => {
const run = service.run();
await jest.advanceTimersByTimeAsync(1000);
await run;
expect(api.request).toHaveBeenCalledTimes(1);
expect(api.retry).toHaveBeenCalledTimes(1);
expect(api.retry).toHaveBeenCalledWith({ delay: 1000 });
});
});
```
## Outputs
- Test files and config updated to Jest (imports, lifecycle, matchers, runners).
- Evidence that the suite runs under Jest with equivalent or improved coverage.
## Guardrails
- **Must** preserve async behavior, timer behavior, and module mocking semantics explicitly.
- **Must** use `await jest.advanceTimersByTimeAsync(n)` — not `jest.advanceTimersByTime(n)` — when the original test used `clock.tickAsync()` inside an async body. Using the synchronous variant silently breaks async ordering.
- **Must not** do bulk mechanical rewrites without validation — migrate in small batches.
- **Should** keep test names and intent stable unless the user asks for broader cleanup.
- **Should** watch for memory or environment differences in CI after migration.From matt-riley/agent-skills, GPL-3.0.
More from matt-riley/agent-skills
- 0.614score
code-intelligence
matt-riley
Use when navigating or refactoring code — choosing between LSP, rg, or semantic search tools; an LSP call returns empty and you need to know if it failed; or…
SkillAFreshness: A★ 4Claude Code +9 - 0.614score
code-tour
matt-riley
Use when asked to create a .tour walkthrough — onboarding, PR review, RCA, architecture, or any persona-targeted step-by-step code narrative.
SkillAFreshness: A★ 4Claude Code +9 - 0.614score
agent-governance
matt-riley
Use this skill when building AI agents that call external tools, implementing policy-based access controls, adding semantic intent classification, creating…
SkillAFreshness: A★ 4Claude Code +9 - 0.614score
agentic-eval
matt-riley
Use when designing or implementing an evaluation loop for AI agent outputs — reflection loops, evaluator-optimizer pipelines, LLM-as-judge scoring, or…
SkillAFreshness: A★ 4Claude Code +9 - 0.614score
api-smoke-validation
matt-riley
Use when running quick, repeatable API smoke tests after changes with hurl, including auth, status-code, response-shape, endpoint sanity, and pre-integration…
SkillAFreshness: A★ 4Claude Code +9 - 0.614score
aws-sdk-v2-to-v3-migration
matt-riley
Use when the codebase still imports from 'aws-sdk' v2, uses new AWS.*() constructors, .promise() calls, AWS.config.update(), DocumentClient, or s3.upload() —…
SkillAFreshness: A★ 4Claude Code +9 - 0.614score
circleci-to-github-actions-migration
matt-riley
Use when a repository still depends on .circleci/config.yml jobs, workflows, or artifacts that need to be replaced or phased out with GitHub Actions —…
SkillAFreshness: A★ 4Claude Code +9 - 0.614score
project-references-migration
matt-riley
Use when a layered TypeScript workspace needs an incremental project-references migration without breaking package boundaries or editor resolution.
SkillAFreshness: A★ 4Claude Code +9 - 0.614score
ast-grep
matt-riley
Use when you need ast-grep structural search, linting, or safe codemod rewrites, especially for requests that mention ast-grep, sg, codemod, rule files, or…
SkillAFreshness: A★ 4Claude Code +9 - 0.614score
agent-instructions
matt-riley
Use when creating or updating agent instruction files (AGENTS.md for Pi, copilot-instructions.md for Copilot, per-path guides, or AGENTS.md router) —…
SkillAFreshness: A★ 4Claude Code +9 - 0.614score
autoresearch
matt-riley
Use when running autonomous iterative experiments to optimize a measurable metric on an existing codebase — not for writing tests or diagnosing a specific…
SkillAFreshness: A★ 4Claude Code +9 - 0.614score
aws-lambda-go-deployment
matt-riley
Use when deploying or debugging Go-based AWS Lambda packaging, bootstrap, runtime, or handler issues — not when the main failure is SAM stack wiring, IAM OIDC…
SkillAFreshness: A★ 4Claude Code +9
Signals
- Stars
- 4
- Forks
- 0
- Open issues
- 1
- Last commit (this folder)
- Jun 28, 2026 (4 months ago)
- Last release
- Oct 23, 2026 (8 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- Version
- 1.0.0
- License
- GPL-3.0
- Repository
- github.com/matt-riley/agent-skills
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from matt-riley
- 0.614score
agent-instructions
matt-riley
Use when creating or updating agent instruction files (AGENTS.md for Pi, copilot-instructions.md for Copilot, per-path guides, or AGENTS.md router) —…
SkillAFreshness: A★ 4Claude Code +9 - 0.614score
agent-supply-chain
matt-riley
Use this skill when generating SHA-256 integrity manifests for agent plugins, verifying that installed plugins match their manifests, detecting tampered…
SkillAFreshness: A★ 4Claude Code +9 - 0.614score
agentic-eval
matt-riley
Use when designing or implementing an evaluation loop for AI agent outputs — reflection loops, evaluator-optimizer pipelines, LLM-as-judge scoring, or…
SkillAFreshness: A★ 4Claude Code +9 - 0.614score
api-smoke-validation
matt-riley
Use when running quick, repeatable API smoke tests after changes with hurl, including auth, status-code, response-shape, endpoint sanity, and pre-integration…
SkillAFreshness: A★ 4Claude Code +9 - 0.614score
aws-sdk-v2-to-v3-migration
matt-riley
Use when the codebase still imports from 'aws-sdk' v2, uses new AWS.*() constructors, .promise() calls, AWS.config.update(), DocumentClient, or s3.upload() —…
SkillAFreshness: A★ 4Claude Code +9 - 0.614score
agent-governance
matt-riley
Use this skill when building AI agents that call external tools, implementing policy-based access controls, adding semantic intent classification, creating…
SkillAFreshness: A★ 4Claude Code +9
Done for you
Rather not set it up yourself?
Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.
See how we build AI agents →Read the case studies
Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.
- launches shipped
- 50+
- launches shipped
- media placements
- 500+
- media placements
- founders on every account
- 2
- founders on every account
Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block
Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.
Get mocha-to-jest-migration running in your business
Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.
Cite this page
mocha-to-jest-migration skill. Agent Mart. https://agentmart.dev/skills/matt-riley-mocha-to-jest-migration (last updated 2026-10-24)