Need advice about which tool to choose?Ask the StackShare community!
Enzyme vs Mocha: What are the differences?
Enzyme: JavaScript Testing utilities for React, by Airbnb. Enzyme is a JavaScript Testing utility for React that makes it easier to assert, manipulate, and traverse your React Components' output; Mocha: Simple, flexible, fun javascript test framework for node.js & the browser. 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.
Enzyme and Mocha can be primarily classified as "Javascript Testing Framework" tools.
Enzyme and Mocha are both open source tools. It seems that Mocha with 18K GitHub stars and 2.43K forks on GitHub has more adoption than Enzyme with 17.4K GitHub stars and 1.91K GitHub forks.
Sellsuki, Onedio, and triGo GmbH are some of the popular companies that use Mocha, whereas Enzyme is used by Airbnb, StyleShare Inc., and Redox Engine. Mocha has a broader approval, being mentioned in 397 company stacks & 268 developers stacks; compared to Enzyme, which is listed in 51 company stacks and 32 developer stacks.
Postman will be used to do integration testing with the backend API we create. It offers a clean interface to create many requests, and you can even organize these requests into collections. It helps to test the backend API first to make sure it's working before using it in the front-end. Jest can also be used for testing and is already embedded into React. Not only does it offer unit testing support in javascript, it can also do snapshot testing for the front-end to make sure components are rendering correctly. Enzyme is complementary to Jest and offers more functions such as shallow rendering. UnitTest will be used for Python testing as it is simple, has a lot of functionality and already built in with python. Sentry will be used for keeping track of errors as it is also easily integratable with Heroku because they offer it as an add-on. LogDNA will be used for tracking logs which are not errors and is also a Heroku add-on. Its good to have a separate service to record logs, monitor, track and even fix errors in real-time so our application can run more smoothly.
We use Mocha for our FDA verification testing. It's integrated into Meteor, our upstream web application framework. We like how battle tested it is, its' syntax, its' options of reporters, and countless other features. Most everybody can agree on mocha, and that gets us half-way through our FDA verification and validation (V&V) testing strategy.
Pros of Enzyme
Pros of Mocha
- Open source137
- Simple102
- Promise support81
- Flexible48
- Easy to add support for Generators29
- For browser and server testing12
- Curstom assertion libraries7
- Works with Karma5
- No other better tools3
- Simple setup1
- Works with saucelabs1
- Lots of tutorials and help online1
- Default reporter is nice, clean, and itemized1
- Works with BrowserStack1
- Simple integration testing1
Sign up to add or upvote prosMake informed product decisions
Cons of Enzyme
Cons of Mocha
- Cannot test a promisified functions without assertion3
- No assertion count in results2
- Not as many reporter options as Jest1