Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Unit Testing Introducing Unit Testing Running Your First Automated Test

Tony Brackins
Tony Brackins
28,766 Points

Mocha vs Jasmine?

Just wondering why we're using Mocha and not Jasmine as I've heard Jasmine is the standard.

Thanks!

Roger Hwang
Roger Hwang
3,851 Points

The great debate begins after popping open another can of worms! Too many choices like a supermarket. I'd say just learn any testing framework to understand its general concept from the start instead of getting into an analysis paralysis debate on frameworks.

1 Answer

Updated article for 2017: https://medium.com/powtoon-engineering/a-complete-guide-to-testing-javascript-in-2017-a217b4cd5a2a

TL;DR:

In short, if you want to β€œjust get started” or looking for a fast framework for large projects, go with Jest. If you want a very flexible and extendable configuration, go with Mocha. If you are looking for simplicity go with Ava.

2019 Update: We still use Mocha at work for all of our back-end NodeJS services. It gets the job done, but lacks the developer experience you get from more modern testing frameworks. Since our front-end is AngularJS/Angular, we use the Karma/Jasmine combination that is the standard within the Angular community. Outside of work, I've moved towards Ava (with Supertest) for back-end unit testing as it includes really simple assertions, is lightweight, and supports TypeScript out of the box. For front-end, I prefer Jest for testing React/Vue components and Cypress for end-to-end testing.