Feature-rich JavaScript test framework for Node.js and the browser
open sourceMITfree
Mocha is a JavaScript test framework that runs on Node.js and in the browser and makes asynchronous testing straightforward: tests can return promises, use async functions or call done(). Tests run serially by default, which keeps reporting accurate and maps uncaught exceptions to the right test, and a parallel mode runs files across workers. It has hooks, exclusive, pending, retried and dynamic tests, root hook plugins and global fixtures, BDD, TDD, QUnit and exports interfaces, and many reporters (spec, dot, TAP, JSON, xUnit, HTML and more). It brings no assertion library of its own, so it's usually paired with one such as Chai or Node's assert. It's an OpenJS Foundation project, supported by sponsors and backers on Open Collective.
Problems it solves
- write and run unit tests for my Node.js code
- test async JavaScript code that uses promises or callbacks
- run the same JavaScript tests in Node and in a browser
Features
- async testing with promises, async functions and done callbacks
- serial runs with accurate reporting; parallel mode
- hooks, exclusive, pending, retried and dynamic tests
- BDD, TDD, QUnit and exports interfaces
- many built-in and third-party reporters
- runs in Node.js and browsers
- bring your own assertion library
Capabilities
| Has a command line tool | plan not known |
|---|---|
| Takes plugins | plan not known |
Alternatives
The same job
These do what Mocha does.