Closed revathskumar closed 10 years ago
The idea itself sounds great to me. Are you looking for more thoughts on implementation or in general whether it is worth pursuing?
I am looking for the thoughts on implementation since, I believe we should be able to added more test frameworks and capabilities in future with ease.
Also for implementing RequireJS/Coffee/both support for tests, I like to separate every concerns which will make us easy to implement and test more feature. So while implementing RequireJS for mocha I like another sub-generator something like generator-backbone-mocha-rjs.
Also I like to know Is there any way my subgenerator (generator-backbone-mocha) can subscribe to events from generator-backbone so that I can avoid this.hookFor
for every test generators.
Well, I think you could extend the default generator-backbone
by requiring the constructors and extending them... (Though you may want to mixin them, as using inheritance won't run prototypes method by default).
Then, you could decorate some methods or use some AOP style to wrap around the methods and generate your test. Though, I wouldn't be confident any of this would be any cleaner than using hookFor.
What we did on generator-bbb is using Karma to run all test and including QUnit, Jasmine and Mocha tests right off. This was easier as Karma was a single config and we could just changes the test frameworks.
https://github.com/backbone-boilerplate/generator-bbb/blob/master/lib/generators/app/index.js#L135-L173 (testScaffolding
and genGruntfile
methods)
One of these days I need to sit down and have a proper look through the generator-bbb source. Looks like you pulled off lots of interesting tricks in there, Simon :)
@SBoudrias I am almost finished generator-backbone-mocha. Now I need to integrate it with generator-backbone. I thinking of moving forward with this.hookFor
for the time being.
But I am just curious about requiring generator-backbone and inheritance, I have some doubts.
You'd only need peerDependency using hookFor
. If you extend them, then you'd place them as dependency and require
the parent generator in the related modules.
I am working on generator-backbone-mocha for generating mocha specs for
collection
,model
,router
andview
.I am planning something like this for mocha as well as jasmine. I like to know your comments.
cc \ @passy @sindresorhus @SBoudrias @addyosmani Thanks