Repolode
mochajs

mochajs/mocha

A widely used JavaScript test framework for Node.js and the browser, providing describe/it-style test structure and async test support.

Stars
22,910
Forks
3,139
Open issues
232
Last commit
11 hours ago

What is it?

Mocha is a JavaScript test framework that runs in Node.js and in the browser. It gives developers a structure for organizing test suites and individual test cases, and it runs them asynchronously, so tests that involve callbacks, promises, or async functions can be written naturally.

Mocha is a runner rather than an assertion library, so it is typically paired with an assertion tool such as Chai or Node's built-in assert module. It supports multiple interface styles, including BDD (describe/it) and TDD, and it is available as a command-line tool. The project is maintained under the OpenJS Foundation and is one of the most depended-upon modules on npm.

Key features

  • 01Runs tests in both Node.js and the browser.
  • 02Supports BDD (describe/it) and TDD interface styles.
  • 03Handles asynchronous tests using callbacks, promises, and async/await.
  • 04Provides a command-line tool for running test suites.
  • 05Works with any assertion library, such as Chai or Node's assert.

Use cases

  • Writing unit tests for Node.js backend services or libraries.
  • Running browser-based tests for front-end JavaScript code.
  • Adding a structured test suite to an existing JavaScript project.

Quick start

  1. 1

    Install Mocha as a dev dependency with npm

    npm install --save-dev mocha

Things to know

  • Maintained exclusively by volunteers.

In collections

Topics

FAQ

What is mocha?
A widely used JavaScript test framework for Node.js and the browser, providing describe/it-style test structure and async test support. Mocha is a JavaScript test framework that runs in Node.js and in the browser. It gives developers a structure for organizing test suites and individual test cases, and it runs them asynchronously, so tests that involve callbacks, promises, or async functions can be written naturally.
Is mocha free to use? What license does it have?
mocha is open source under the MIT license. Check the license terms before using it in commercial products.
Is mocha still maintained?
Actively maintained. The last commit to mocha was on Oct 24, 2026.
What can I use mocha for?
Writing unit tests for Node.js backend services or libraries. Running browser-based tests for front-end JavaScript code. Adding a structured test suite to an existing JavaScript project.
How do I install mocha?
Install Mocha as a dev dependency with npm: npm install --save-dev mocha
Where can I get mocha?
The source code and installation instructions are on GitHub: https://github.com/mochajs/mocha

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects