mocha
Installation
SKILL.md
Mocha
Mocha is a flexible JavaScript test framework. Unlike Jest, it does not come with an assertion library, mocking, or snapshotting built-in. It is a runner that allows you to choose your own tools (usually Chai + Sinon).
When to Use
- Flexible Node.js & Browser Testing: A customizable test runner providing BDD (
describe/it) and TDD test interfaces. - Customizable Assertion & Mocking Pairs: Pairing with preferred assertion libraries (Chai) and mocking toolkits (Sinon.js).
- Asynchronous Execution Control: Testing callbacks, promises, and async/await with granular timeout controls.
- Established Node.js Codebases: Maintaining and extending mature enterprise backend JavaScript services.
Quick Start
// npm install --save-dev mocha chai
const assert = require("chai").assert;