# Why is Jasmine used as default instead of Mocha? #117

Closed
opened this Issue Jul 3, 2012 · 32 comments

Projects
None yet
6 participants
Contributor

### paulmillr commented Jul 3, 2012

 Jasmine is a bloated and has great problems with support. For example, maintainer firstly commented on opened pull request after nine months. Mocha has very flexible syntax via Chai.js, much more features and cool reporters.
Member

### addyosmani commented Jul 3, 2012

 I personally wouldn't mind us switching over to using Mocha. It wouldn't be too difficult, the basic describe and BDD patterns are about the same. One does have to update their assertions to a different interface for async tests but they're similar feature wise. Some would say Mocha's async interface is more consistent and a little simpler. A con is that Jasmine matchers are easier to read whilst if using Mocha you would probably pair it with Chai to handle assertions. Personally like Jasmine's style a little more as it feels elegant, but again, it comes down to personal preference. Jasmine pros Arguably more developers have experience with it and are using it in their projects given how long its been around (Also, silly metric but 3.5K watchers vs 1.5K) Easy to find Jasmine tutorials for most MV* frameworks, whilst Mocha is still considered the new kid on the block. Mature (I see as many people using it as QUnit in the wild) cons Paul is right in that Pivotal aren't responsive to pull requests, though they have made repo changes within < 3 months Bloated? Mocha is in more active development at the moment and it really isn't that much effort to switch over to it. I would say more new projects are using it over Jasmine.
Contributor

### mklabs commented Jul 3, 2012

 FWIW, I kinda like mocha over Jasmine as well. The BDD ui is pretty much similar to Jasmine, but what makes me prefer mocha is that it works roughly the same to test nodejs and frontend stuff (and as a node developer, this is a huge argument for me in favor to mocha). Plus, as you mentioned, it has some nice features (like the string diff output, test threshold, support for code coverage, etc.) and cool reporters (btw, we use mocha to test the yeoman cli). We have a pretty good support of Jasmine right now. Even though I'm a fan of Mocha, I'm not sure that switching to Mocha as default is the right thing to do right now (especially for v1, considering the amount of work left). What I ideally want though is to provide the possibility to user to use their preferred test framework, in some way. I'll certainly be one of the user who will try to use Mocha instead of Jasmine. Generators might help here.
Member

### addyosmani commented Jul 3, 2012

 Agreed. IMO, this is a V2 item unless someone is willing to work on an implementation in branch/fork for V1.
Member

### sindresorhus commented Jul 3, 2012

 I also prefer Mocha because of the reasons stated above (especially because of the nyancat reporter). Using generators for this sounds like a good idea.
Member

### addyosmani commented Jul 3, 2012

 Side-note, but technically I imagine there are quite a few places in our current architecture that could be replaced with generators. If we're using them for the unit testing solution, does it also make sense to pipe yeoman init back through to a generator too? Just wondering if that would simplify things.
Contributor

### paulmillr commented Jul 5, 2012

 I'm willing to work on Mocha transfer. Will submit pull in a bit.
Contributor

### mklabs commented Jul 6, 2012

 @paulmillr That would be great! You might want to take a look at https://github.com/mklabs/yeoman/tree/generators/cli/lib/generators/mocha I did yesterday a few tests on mocha, to see how it goes with generators. I was just playing around with the idea. In the process, I tried to integrate grunt-mocha to be able to run these tests headlessly as we do currently for Jasmine. It may be related to my environment, but I got some issue. kmiyashiro/grunt-mocha#5 is related. It seems to work with this workaround.
Contributor

### paulmillr commented Jul 6, 2012

 @mklabs 404
Contributor

### mklabs commented Jul 6, 2012

 Ok, I don't know how I can give you access to my fork. I'm guessing it's related to some permission issue. I added the yeoman-preview team, is it the right thing to do? cc @addyosmani
Contributor

### paulmillr commented Jul 6, 2012

 actually now it seem to work
Member

### addyosmani commented Jul 6, 2012

 It should work without special permissions if you're able to view master. On Jul 6, 2012 12:45 PM, "Paul Miller" < reply@reply.github.com> wrote: actually now it seem to work Reply to this email directly or view it on GitHub: #117 (comment)
Member

### addyosmani commented Jul 8, 2012

 @paulmillr how are things looking on the Mocha front? :)
Contributor

### paulmillr commented Jul 8, 2012

 @addyosmani not ready yet, currently busy with doing the same thing to Chaplin, pretty a lot of tests there.

Member

### paulirish commented Jul 18, 2012

 I liked your Mocha PR for Chaplin. The reasons you give for dropping jasmine are sound. Let's do it
Member

 ✨ 😄 ✨
Contributor

### paulmillr commented Jul 18, 2012

 i've ran into a support issue with chaplin. does yeoman need to support ie8? otherwise we won't be able to use awesome chai.js
Member

### addyosmani commented Jul 18, 2012

 @paulmillr is it things like this that make ie8 support hard? chaijs/chai#7
Member

### sindresorhus commented Jul 18, 2012

 I don't see a reason why we should support oldIE when testing. No decent web dev uses that as their main browser.
Contributor

### paulmillr commented Jul 18, 2012

 @addyosmani no, it's property descriptors. Getters / setters aren't supported in shitIE, as you know.
Contributor

### paulmillr commented Jul 18, 2012

 I mean this: expect(user).to.be.ok
Member

### paulirish commented Jul 18, 2012

 Yeoman does not support IE8. We have it documented as supporting IE10 at the moment. I don't expect to change that. So we're good. 👌
Contributor

 👍
Member

### addyosmani commented Jul 27, 2012

 @paulmillr do you think you might have a chance to put together a PR with the Mocha replacement in the next week or two?
Contributor

### paulmillr commented Jul 27, 2012

 sure, most likely on this weekend. I've tried to find the place we store default app with jasmine tests, but no chance. Could anyone point me at it?
Member

### addyosmani commented Jul 27, 2012

 When you say the default app, do you mean the app created when you run yeoman init? If so, this is located under lib -> generators -> yeoman -> simpleapp.
Contributor

### paulmillr commented Jul 27, 2012

 right, thanks
Member

### paulirish commented Aug 5, 2012

 @paulmillr if you got time to PR for Mocha we'd love to make moves to it.
Contributor

### paulmillr commented Aug 7, 2012

 sorry guys, have been buried in brunch / chaplin / work projects.
Member

### addyosmani commented Aug 7, 2012

 @paulmillr Do you think you might get a chance to look at this in the next 1-2 weeks? If not, I think it'll probably get shelved for v2.
Contributor

Member

### addyosmani commented Aug 7, 2012

 @paulmillr Thanks! I'll reply on #187 :)

Merged

### mklabs added a commit to mklabs/yeoman that referenced this issue Aug 31, 2012

 server - slight changes to server task to also serve files from temp/ 
and addition of three subtargets app (default), prod (serve dist) and test
(serve test/)

Also updated the way server runs other tasks on start, if the target is "app",
then a new clean coffee compass set of tasks is run, then the watch task is
triggered.

related to yeoman#117. should close yeoman#80, yeoman#206 and yeoman#103

might evolve a bit, need a bit more work / tests
 e3bf291 

Closed

### szinya pushed a commit to menthainternet/yeoman that referenced this issue Sep 17, 2014

 server - slight changes to server task to also serve files from temp/ 
and addition of three subtargets app (default), prod (serve dist) and test
(serve test/)

Also updated the way server runs other tasks on start, if the target is "app",
then a new clean coffee compass set of tasks is run, then the watch task is
triggered.

related to yeoman#117. should close yeoman#80, yeoman#206 and yeoman#103

might evolve a bit, need a bit more work / tests
 8c0b043 

Open

### mklabs added a commit that referenced this issue Apr 24, 2015

 server - slight changes to server task to also serve files from temp/ 
and addition of three subtargets app (default), prod (serve dist) and test
(serve test/)

Also updated the way server runs other tasks on start, if the target is "app",
then a new clean coffee compass set of tasks is run, then the watch task is
triggered.

related to #117. should close #80, #206 and #103

might evolve a bit, need a bit more work / tests
 27bd910 

### LechDvorak commented Apr 28, 2016

 I think you have a little more flexibility when using Mocha, since you can pick your own assertion library and your own mocking library. This however also comes with a price of a slightly more complex setup and some additional dependencies. Overall I think it depends on each project or your personal preference which of these libraries you want to use. When using Jasmine this does not exclude you from using Sinon. You can still benefit for example from its fake server. Both frameworks are perfectly able to do the job. As of Jasmine 2.x, I think Jasmine is back in the race with Mocha. Interesting thoughts also here https://www.apriorit.com/dev-blog/372-testing-javascript-with-jasmine