Jasmine vs Mocha: What are the differences?
"Can also be used for tdd " is the primary reason why developers consider Jasmine over the competitors, whereas "Open source" was stated as the key factor in picking Mocha.
Jasmine and Mocha are both open source tools. Mocha with 18K GitHub stars and 2.43K forks on GitHub appears to be more popular than Jasmine with 14.4K GitHub stars and 2.12K GitHub forks.
Sellsuki, Onedio, and triGo GmbH are some of the popular companies that use Mocha, whereas Jasmine is used by Coderus, Infoshare, and Ztory. Mocha has a broader approval, being mentioned in 397 company stacks & 268 developers stacks; compared to Jasmine, which is listed in 143 company stacks and 75 developer stacks.
What is Jasmine?
What is Mocha?
Need advice about which tool to choose?Ask the StackShare community!
Sign up to add, upvote and see more prosMake informed product decisions
What are the cons of using Mocha?
Sign up to get full access to all the companiesMake informed product decisions
Sign up to get full access to all the tool integrationsMake informed product decisions
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!
We used to Mocha for as our primary Node.js test framework. We've now switched to Jest and haven't looked back.
Jest is faster and requires less setup and configuration. The Mocha API and eco-system is vast and verified, but that also brings complexity.
It you want to get in, write tests, execute them and get out, try Jest 😀
We use JUnit and Jest to perform the bulk of our automated test scenarios, with additional work with Apache JMeter for performance testing - for example, the Atlassian Data Center compliance testing is performed with JMeter. Jest provides testing for the React interfaces, which make up the backend of our App offerings. JUnit is used for Unit Testing our Server-based Apps. Mocha is another tool we use.
This is a trending topic on Automation testing for E2E web applications.
Now, new guy in town Cypress does not use Selenium and runs directly in your app without any json wire protrocol, but it does not support parallel testing or mobile testing.
Have you experienced both? Should I stick with old and known ?
#testing cypress #selenium qaautomation #qa
Used for unit testing when working with Node.js. Used over other testing frameworks because of good compatibility with TypeScript and ts-node.
We use Jasmine for all our front-end web interface tests. Works great for testing all our Angular components.