StackShareStackShare
Follow on
StackShare

Discover and share technology stacks from companies around the world.

Product

  • Stacks
  • Tools
  • Companies
  • Feed

Company

  • About
  • Blog
  • Contact

Legal

  • Privacy Policy
  • Terms of Service

© 2025 StackShare. All rights reserved.

API StatusChangelog
Mocha
ByMochaMocha

Mocha

#3in Testing Frameworks
Stacks8.87kDiscussions25
Followers2.99k
OverviewDiscussions25

What is Mocha?

Mocha is a feature-rich JavaScript test framework running on node.js and the browser, making asynchronous testing simple and fun. Mocha tests run serially, allowing for flexible and accurate reporting, while mapping uncaught exceptions to the correct test cases.

Mocha is a tool in the Testing Frameworks category of a tech stack.

Key Features

browser supportsimple async support, including promisestest coverage reportingstring diff supportjavascript API for running testsproper exit status for CI support etcauto-detects and disables coloring for non-ttysmaps uncaught exceptions to the correct test caseasync test timeout supporttest-specific timeoutsgrowl notification supportreports test durationshighlights slow testsfile watcher supportglobal variable leak detection

Mocha Pros & Cons

Pros of Mocha

  • ✓Open source
  • ✓Simple
  • ✓Promise support
  • ✓Flexible
  • ✓ Easy to add support for Generators
  • ✓For browser and server testing
  • ✓Curstom assertion libraries
  • ✓Works with Karma
  • ✓No other better tools
  • ✓Default reporter is nice, clean, and itemized

Cons of Mocha

  • ✗Cannot test a promisified functions without assertion
  • ✗No assertion count in results
  • ✗Not as many reporter options as Jest

Mocha Alternatives & Comparisons

What are some alternatives to Mocha?

Jest

Jest

Jest provides you with multiple layers on top of Jasmine.

Chai

Chai

It is a BDD / TDD assertion library for node and the browser that can be delightfully paired with any javascript testing framework. It has several interfaces that allow the developer to choose the most comfortable. The chain-capable BDD styles provide an expressive language & readable style, while the TDD assert style provides a more classical feel.

Jasmine

Jasmine

Jasmine is a Behavior Driven Development testing framework for JavaScript. It does not rely on browsers, DOM, or any JavaScript framework. Thus it's suited for websites, Node.js projects, or anywhere that JavaScript can run.

Cypress

Cypress

Cypress is a front end automated testing application created for the modern web. Cypress is built on a new architecture and runs in the same run-loop as the application being tested. As a result Cypress provides better, faster, and more reliable testing for anything that runs in a browser. Cypress works on any front-end framework or website.

SinonJS

SinonJS

It is a really helpful library when you want to unit test your code. It supports spies, stubs, and mocks. The library has cross browser support and also can run on the server using Node.js.

Protractor

Protractor

Protractor is an end-to-end test framework for Angular and AngularJS applications. Protractor runs tests against your application running in a real browser, interacting with it as a user would.

Mocha Integrations

Karma, React.js Boilerplate, CrossBrowserTesting , Chakram, Wallaby.js and 4 more are some of the popular tools that integrate with Mocha. Here's a list of all 9 tools that integrate with Mocha.

Karma
Karma
React.js Boilerplate
React.js Boilerplate
CrossBrowserTesting
CrossBrowserTesting
Chakram
Chakram
Wallaby.js
Wallaby.js
LambdaTest
LambdaTest
Testomat
Testomat
Allure Report
Allure Report
promptfoo
promptfoo

Mocha Discussions

Discover why developers choose Mocha. Read real-world technical decisions and stack choices from the StackShare community.Showing 2 of 5 discussions.

Juan Morales
Juan Morales

Feb 12, 2019

Needs adviceonNode.jsNode.jsGraphQLGraphQLMongoDBMongoDB

I just finished the very first version of my new hobby project: #MovieGeeks. It is a minimalist online movie catalog for you to save the movies you want to see and for rating the movies you already saw. This is just the beginning as I am planning to add more features on the lines of sharing and discovery

For the #BackEnd I decided to use Node.js , GraphQL and MongoDB:

  1. Node.js has a huge community so it will always be a safe choice in terms of libraries and finding solutions to problems you may have

  2. GraphQL because I needed to improve my skills with it and because I was never comfortable with the usual REST approach. I believe GraphQL is a better option as it feels more natural to write apis, it improves the development velocity, by definition it fixes the over-fetching and under-fetching problem that is so common on REST apis, and on top of that, the community is getting bigger and bigger.

  3. MongoDB was my choice for the database as I already have a lot of experience working on it and because, despite of some bad reputation it has acquired in the last months, I still believe it is a powerful database for at least a very long list of use cases such as the one I needed for my website

0 views0
Comments
Dschinkel Schinkel
Dschinkel Schinkel

Nov 30, 2018

Needs adviceonMochaMochaJestJestJavaScriptJavaScript

I use both mocha and Jest because:

  • I don't care whether teams use Jest or Mocha. But jest is way too overhyped. Most devs are writing integration tests and think that it's so much better but frankly I don't write integration tests as the way to get both design feedback and confidence when I code. I adhere to the test pyramid, not ice cream cone or the dumb "trophy"

  • I TDD, so I only ever use the "API" of test frameworks. I don't do a lot of integration tests for TDD and all the bells and whistles Jest provides you from the command-line I just don't need. And I certainly do not care about or touch Jest Snapshots, I despise them

  • My tests are fast enough because I write isolated tests with TDD, so I don't run into performance issues. Example: I write my tests in a way that I can run 300 tests in literally 1 second with mocha. So the Jest ability to pinpoint and only run those tests which are affected by code changes. I want to run all of them every time when I TDD. It's a different mindset when you TDD

  • I also mainly code in IntelliJ or WebStorm because I feel the tools in that IDE far surpass VSCode and I also love running the test UI runner in it vs. lousy command-line

  • I feel both mocha and Jest read just fine in terms of code readability. Jest might have shorter assertion syntax but I don't really care. I just care that I can read the damn test and my tests are written well and my test descriptions, as well as the code itself including constants represent business language, not technical. I care most about BDD, clean code, 4 rules of simple design, and SOLID

  • I don't like using mock frameworks so no I don't use Jest's Mocking framework. I don't have to mock a lot in my tests due to the nature of how I strive to code...I keep my design simple and modular using principals such as clean code and 4 rules of simple design. If I must mock, I create very simple custom mocks with JS

  • On the contrary to the belief that integration tests and mount are the way to go (this belief drives me absolutely crazy, especially Dodd's promoting that), I TDD with shallow & enzyme. My tests are simple. My design is driven by my tests and my tests give me quick and useful feedback. I have a course I'm working on coming out soon on TDD with React to show you how to truly test the FE and why the ice cream cone and trophy suck (you're being scammed people). Watch for that here: https://twitter.com/DaveSchinkel/status/1062267649235791873

Don't forget to upvote this post!

Mocha Jest JavaScript React @jsdom Enzyme ##tdd ##bdd ##testdrivendevelopment

0 views0
Comments
View all 5 discussions

Try It

Visit Website

Adoption

On StackShare

Companies
799
ACDINO+793
Developers
3.07k
YRNBAM+3065