Dev Resources
Mocha favicon

Mocha

Testing

Simple, flexible, fun JavaScript test framework for Node.js and the browser.

Mocha's website screenshot

About Mocha

Mocha is a JavaScript test framework that runs on Node.js and in the browser. It supports asynchronous testing, running tests serially so that reporting stays accurate and uncaught exceptions are mapped to the correct test cases.

The framework supports multiple test interfaces (including BDD and TDD), a range of built-in reporters, and third-party reporters and UIs. It also provides features such as global fixtures, hooks, retrying tests, parallel mode, and a programmatic and JavaScript API for custom usage.

Mocha is aimed at JavaScript developers writing tests for Node.js or browser-based projects. Documentation covers configuration, CLI usage, editor plugins, and explainers on topics such as spies, shared behaviours, and detecting global leaks.

Key features

  • Runs JavaScript tests on Node.js and in the browser
  • Supports asynchronous testing
  • Runs tests serially for flexible and accurate reporting
  • Maps uncaught exceptions to the correct test cases
  • Supports multiple test interfaces (BDD, TDD, QUnit, Exports)
  • Supports third-party reporters

Frequently asked questions

What platforms does Mocha run on?

Mocha runs on Node.js and in the browser.

Does Mocha support asynchronous tests?

Yes, Mocha is designed to make asynchronous testing straightforward.

How are tests executed in Mocha?

Mocha tests run serially, which allows for flexible and accurate reporting and maps uncaught exceptions to the correct test cases.

Is Mocha free to use?

Mocha is an open-source project supported by sponsors and backers rather than a paid product.

Who maintains Mocha?

Mocha is maintained by the OpenJS Foundation and its contributors.

Advertise here

Featured products

  • SerpApi - Search API favicon
  • CoreClaw favicon

Show your product to thousands of developers

· 100k monthly pageviews
· 7k newsletter subscribers

Advertise your product

You might also like