flightjs / generator-flight-package

A Yeoman generator for scaffolding a Flight package
http://flightjs.github.io
MIT License
10 stars 7 forks source link

Option to generate tests using mocha/sinon/chai instead of jasmine #6

Open traviskaufman opened 10 years ago

traviskaufman commented 10 years ago

Hello! First off, thank you for such an awesome web application framework. I'm writing this as the contribution guide says to "ask first before embarking on any significant pull request"

I was using flight to build out an internal tool at my company, where we use mocha, sinon, and chai for testing our front-end code. I used this generator to initially set up the application, and noticed that switching out jasmine and using these libraries instead can take a bit of time. I love flight and plan on using it as my go-to framework for future projects, but I also prefer to use mocha/sinon/chai over jasmine, so it would be great if this generator could accept options to configure tests using them instead of jasmine.

Why mocha, sinon, and chai?

Since there is already a flight extensions for mocha, I figured that it should follow that the generator for mocha could support setting up tests for a framework which extensions have already been written.

I chose chai because it is a very robust assertion library but is also highly configurable and non-prescriptive about what kind of assertions you use (assert, expect, etc.). In fact, I'd also love to see some chai extensions for flight as well, but I digress.

I chose sinon because, well, personally I love sinon :smiley: . But more than that also because I find it nicely fills in for jasmine's spies (and thensome), and also provides pretty much all utilities needed to easily perform js testing such as fake timers, XHRs, etc.

If you feel that adding sinon and chai are too prescriptive, however, I completely understand. But I feel at minimum there should be support for mocha.

As I mentioned in the first paragraph I am more than happy to implement this and submit a pull request for it. Flight has made my life a whole lot easier and ensures that the products shipped with it are always architected in a scalable and sensible way, so I'd love to be able to give back to it.

necolas commented 10 years ago

Hey. Mocha, Chai, and Sinon are my personal preference too (if IE 8 testing isn't needed). Happy for a Pull Request that adds the option(s) to the package generator.

There's already an open issue to implement these options in the generator-flight repo (our flight-based application generator; perhaps you meant to open this issue there?): flightjs/generator-flight#4. It should be much simple now that Yeoman's generator has a better prompt builder. You might want to look there too - https://github.com/flightjs/generator-flight/blob/master/lib/generators/app/index.js

Thanks