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:

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:

For CoffeeScript 1.7 and above use:

The tests/my_test.coffee 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:

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