Running CoffeeScript Mocha tests on Travis CI

Travis CI will run npm test by default, so you will need to add the following to your package.json file:

"scripts": {
"test": "mocha --compilers coffee:coffee-script/register tests/"

"devDependencies": {
"coffee-script": "^1.10.0"

Invoking the npm test command will run the test command in the scripts section.

Mocha does not support CoffeeScript out of the box, so you will need to add the compilers option.

For CoffeeScript 1.6 and under use:

 mocha --compilers coffee:coffee-script

For CoffeeScript 1.7 and above use:

mocha --compilers coffee:coffee-script/register

The tests/ is the test file to execute. You can also set it to use a directory instead (i.e. tests directory in this case).

Now, you just need to setup your .travis.yml file. I followed the instructions from the Travis Docs which resulted in the following .travis.yml file:

language: node_js
- "stable"
# following is from:
- CXX=g++-4.8
- ubuntu-toolchain-r-test
- g++-4.8

Next, turn the CI button on for your repository on the Travis CI site and do a git push. That’s it!