Skip to content
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

Generators create tests #635

Open
ghost opened this issue Aug 2, 2014 · 2 comments
Open

Generators create tests #635

ghost opened this issue Aug 2, 2014 · 2 comments

Comments

@ghost
Copy link

ghost commented Aug 2, 2014

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
Copy link
Contributor

qfox commented Aug 2, 2014

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
Copy link
Author

ghost commented Aug 2, 2014

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant