1602 / compound

MVC framework. Built on Node.JS. Works on server and browser.
http://compoundjs.com
1.6k stars 183 forks source link

Generators create tests #635

Open ghost opened 9 years ago

ghost commented 9 years ago

This is more of a feature request than a bug, but it would be great if the various generators generated mocha tests too by default. Is anyone working on this?

qfox commented 9 years ago

Actually, I don't understand what you talking about. Can you describe it? Good idea but how to do that? Probably for generation we can try to use some existent package like yo or gulp?

ghost commented 9 years ago

I'm thinking of something Rails-like. In a default rails installation, running something like rails generate model User will create, in addition to the model files and database stuff, a basic test file at test/models/user_test.rb. If you install testing suites like RSpec, they automatically change this functionality to create a file at spec/models/user_spec.rb.

It would be handy in compound if running compound generate model User created a file at test/models/user.(js|coffee). That file could look something like this in javascript:

describe('User', function () {
  // Put your tests here
});

or this in coffee:

describe 'User', ->
  # Put your tests here

Also, the default test script in package.json that's created with compound init helloworld is this: ./node_modules/.bin/mocha --require test/init.js test/*/*.test.js

This actually fails without an init.js, which isn't automatically created when the app is. So, compound starts out with failing tests. This line should probably be more like this: mocha test/*/*.(js|coffee), but it would be nice if the init generator also added a file at test/mocha.opts with this:

test/*/*.(js|coffee)

So you could just run mocha and the test script could just be "test": "mocha"