New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why is Jasmine used as default instead of Mocha? #117
Comments
|
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
cons
|
|
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. |
|
Agreed. IMO, this is a V2 item unless someone is willing to work on an implementation in branch/fork for V1. |
|
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. |
|
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 |
|
I'm willing to work on Mocha transfer. Will submit pull in a bit. |
|
@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. |
|
@mklabs 404 |
|
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 |
|
actually now it seem to work |
|
It should work without special permissions if you're able to view master.
|
|
@paulmillr how are things looking on the Mocha front? :) |
|
@addyosmani not ready yet, currently busy with doing the same thing to Chaplin, pretty a lot of tests there. |
|
I liked your Mocha PR for Chaplin. The reasons you give for dropping jasmine are sound. |
|
|
|
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 |
|
@paulmillr is it things like this that make ie8 support hard? chaijs/chai#7 |
|
I don't see a reason why we should support oldIE when testing. No decent web dev uses that as their main browser. |
|
@addyosmani no, it's property descriptors. Getters / setters aren't supported in shitIE, as you know. |
|
I mean this:
|
|
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. |
|
|
|
@paulmillr do you think you might have a chance to put together a PR with the Mocha replacement in the next week or two? |
|
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? |
|
When you say the default app, do you mean the app created when you run |
|
right, thanks |
|
@paulmillr if you got time to PR for Mocha we'd love to make moves to it. |
|
sorry guys, have been buried in brunch / chaplin / work projects. |
|
@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. |
|
@paulmillr Thanks! I'll reply on #187 :) |
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
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
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
|
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 |
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.
The text was updated successfully, but these errors were encountered: