Mocha vs. Jest vs. Jasmine



Hacker News, Reddit, Stack Overflow Stats

  • -
  • -
  • 6.28K
  • 8.59K
  • 2.06K
  • 1.01K
  • 5
  • 2
  • 10.4K

GitHub Stats

Description

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.

What is Jest?

Jest provides you with multiple layers on top of Jasmine.

What is 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.

Want advice about which of these to choose?Ask the StackShare community!

Pros

Why do developers choose Mocha?
Why do you like Mocha?

Why do developers choose Jest?
Why do you like Jest?

Why do developers choose Jasmine?
Why do you like Jasmine?

Cons

What are the cons of using Mocha?
No Cons submitted yet for Mocha
Downsides of Mocha?

What are the cons of using Jest?
No Cons submitted yet for Jest
Downsides of Jest?

What are the cons of using Jasmine?
No Cons submitted yet for Jasmine
Downsides of Jasmine?

Companies

What companies use Mocha?
500 companies on StackShare use Mocha
What companies use Jest?
279 companies on StackShare use Jest
What companies use Jasmine?
193 companies on StackShare use Jasmine

Integrations

What tools integrate with Mocha?
2 tools on StackShare integrate with Mocha
What tools integrate with Jest?
1 tools on StackShare integrate with Jest
What tools integrate with Jasmine?
1 tools on StackShare integrate with Jasmine

What are some alternatives to Mocha, Jest, and Jasmine?

  • Enzyme - JavaScript Testing utilities for React, by Airbnb
  • Protractor - End-to-end test framework for Angular and AngularJS applications
  • AVA - A refined, futuristic test runner
  • Cypress - Cypress provides better, faster, and more reliable testing for anything that runs in a browser.

See all alternatives to Mocha

Latest News

WebStorm 2017.3 EAP, 173.2941: watch mode with Jest ...
Get Started with vue-test-utils and Jest
Related Stack Decisions
Dschinkel Schinkel
Dschinkel Schinkel
Enzyme
React
JavaScript
Jest
Mocha
#Testdrivendevelopment
#Bdd
#Tdd

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

See more


Interest Over Time