4 ms·
My cursory internet sleuthing has revealed that Angular and React use Jasmine, whereas Ember and CoffeeScript use QUnit. Haven't found an instance of Mocha. Mo
by ihsw 11y ago
My cursory internet sleuthing has revealed that Angular and React use Jasmine, whereas Ember and CoffeeScript use QUnit.
Haven't found an instance of Mocha. Most job postings I've seen indicate that Jasmine is the dominant test framework.
- Lazare 11y agoThe official React repo actually used Jest, which is Facebook's own testing framework/test runner/Frankenstein's monster. Basically an old 1.x version of Jasmine, bolted to a test runner, a JSDom environment, and a ton of mostly working automocking magic. It's glacially slow and kind of buggy, and in my experience most projects using React use Mocha, not Jest. And I haven't run across any using actual Jasmine (Jasmine and Jest are neither compatible nor interchangable). As a general rule, I'd say node-based projects are heavily mocha based, whereas browser-based projects are much more mixed. CoffeeScript based projects seem especially likely to use Mocha over Jasmine; Angular (as you noted) has a strong preference for Jasmine due to their Protractor tool, etc. QUnit seems to be used by a lot of libraries and frameworks, but to have almost no usage among projects; I've never seen QUnit tests in the wild except in framework/library repos. And as a final data point, note that on NPM, the main mocha package has almost 5 times the weekly downloads of the main jasmine package.
- pluma 11y agoJasmine is widespread but Mocha is pretty much the norm for modules on NPM. This is in part because Mocha is considerably easier to instrument.
- exogen 11y agoIndeed, it's better in a bunch of ways! The one that finally got me to switch was that Jasmine didn't have an official CLI version for the longest time; it was browser-based and the CLIs were all third-party (and none of them very good). It includes one now, but it was too late.
- pluma 11y agoWe first adopted Jasmine for our internal JavaScript tests in ArangoDB (https://www.arangodb.com https://www.arangodb.com) to replace the ancient and inconvenient framework we were using before. It worked, kinda, but it was a mess. We still needed something to expose to developers wishing to test their own apps in the DB and doing that with Jasmine proved to be pretty much impossible. It was extremely straightforward to integrate with Mocha, though. We just needed to stub out some of the node.js-specific code and provide a very small wrapper to provide our own module loader and reporting plugins. There is an active effort to split up Mocha into multiple modules in order to make it more portable, which would make the stubbing unnecessary, too.
- Lazare 11y agoQuite coincidentally ran across this survey from 2014 that shows Jasmine and Mocha are pretty much neck and neck. https://s3.amazonaws.com/dailyjs/files/2014-survey-summary.pdf https://s3.amazonaws.com/dailyjs/files/2014-survey-summary.p...