Alex Rivera | Logout

CoffeeScript unit testing?

Asked 2010-06-28T04:32:59.057
38

I'm using CoffeeScript in a Rails application, and I would like to unit test it. Google didn't turn up anything, is there any way to do it short of writing my own testing framework or testing the JavaScript that CoffeeScript outputs?

Edit
Report

1 Answer

11

You can use QUnit "as-is", but still only write coffee-script - and no glue-code.
I have a very small, pure coffee-script project on github as an example - rubyann.

The HTML test page rubyann_tests.html, references the rubyann_tests.coffee file which tests jquery.rubyann.coffee. I didn't write any javascript or any other code to make this work.

The tests only run on Chrome on your local machine if you use the command-line argument --allow-file-access-from-files. But it works on Firefox and even IE without issues.

addendum - the tests are also setup to run on the command line via Node/gulp/qunitjs - download the repo and type npm run test

answered 2011-01-10T11:13:56.180

Your Answer