Testing CofeeScript with Mocha

May 01, 2012

By Jamison Dance

Mocha is a JavaScript testing library that is great. It used to just run CoffeeScript out of the box, but recently they factored support out, probably to support all kinds of languages that compile down to JavaScript in the future. The result is, mocha test/foo.coffee no longer works.

To get mocha to run test written in CoffeeScript, run the following:

mocha test/foo.coffee --compliers coffee:coffee-script

Notes to my future self who keeps forgetting this.

Jamison Dance enjoys kittens, making computers smarter and the magic of children's laughter. He tweets at @jergason and GitHubs as jergason. He also podcasts on JavaScript Jabber and Soft Skills Engineering.