When comparing Jasmine vs Mocha, the Slant community recommends Mocha for most people. In the question“What are the best JavaScript unit testing frameworks?” Mocha is ranked 1st while Jasmine is ranked 3rd. The most important reason people chose Mocha is:
Mocha runs independently from the [assertion library](http://visionmedia.github.io/mocha/#assertions), so you can choose which assertion format works best for you. Mocha most often is run in combination with assertion library [Chai](http://chaijs.com).
Ranked in these QuestionsQuestion Ranking
Pros
Pro Behaviour Driven Development focused
If you prefer your test cases and applications to be developed from the perspective of your stake holders, Jasmine is the framework for you.
Pro Easy to find Jasmine tutorials for most MV* frameworks,
whilst Mocha is still considered the new kid on the block.
Pro Has a very readable and user-friendly syntax
Code readability is an important factor, if the application development involves multiple teams; if the testing team is unable to read your test cases then they won't be able to test it. Jasmine resolves this issue by providing developers with an extremely simple and "human-friendly" syntax.
Pro Allows both DOM-less as well as asynchronous testing
If you have some test cases that do not involve testing of DOM elements or events, those are exactly the ones where you want to use Jasmine. It'll provide smooth, simple and easy DOM-less testing of those test cases.
Pro Integrates very well with Ruby on Rails
The jasmine-rails gem allows you to run Jasmine specs in a browser (powered by Rails engine mounted into your application).
Pro Supports different assertion libraries
Mocha runs independently from the assertion library, so you can choose which assertion format works best for you.
Mocha most often is run in combination with assertion library Chai.
Pro Write tests with Behavior Driven Development (BDD)
Allows developers to choose their development process. Not only TDD but also BDD.
Pro Runs in Node.js and the browser
Mocha has a browser build as well as a node command line program so you can test in client and server side environments.
Pro Makes Asynchronous testing extremely easy
No need to write tricky statements for Async testing. Mocha gives you a done
callback. Place this done
parameter in your callback function, that'll let Mocha know that you've written an asynchronous function.
Pro Integrates really well with NodeJS
The Mocha test framework itself runs on NodeJS, hence it makes everything related to it extremely simple. With Mocha's simple syntax and speed, testing your node.js app just got a whole lot easier.
Pro Custom full color test reporters
Mocha has multiple test reporters built in and you can create your own as well. The test reporters have full color and makes it easy to see if your tests fail or not.
Pro Easy to add support for Generators
Aside from the numerous benefits with generators in your application, You can now also integrate generators into your test suite. By using mocha, all you have to do is enable support for generators.
Cons
Con Maintainers are not very responsive to pull requests
Pivotal aren't responsive to pull requests, though they have made repo changes within < 3 months
Con Can be intimidating for beginners
While some testing frameworks are complete out of the box, Mocha requires developers to select and set up assertion libraries and mocking utilities. For someone who is just starting to learn how to build tests this can be scary as they will also have to choose which libraries to use and learn them too.
Con No atomic tests
Tests cannot be ran in random order.