Testing With Meteor, CoffeeScript and Mocha
Despite no mention in the official Meteor docs, adding unit tests is fairly easy. For some reason, they don’t mention this but any files in the tests/ folder will be ignored by the Meteor server.
What you’ll need:
- Growl (for notifications from mocha watch)
1 2 3
Setting up Mocha to watch our coffee files and send Growl notifications:
Now to create a sample test:
1 2 3 4 5
Mocha should notice the file change and run the tests showing you the passing test.
- The growl notification didn’t work for me, but I assume that’s because I’m using an old version.
- When using Mocha watch, sometimes a failing test result would be outputted many times
- Jasmine should also work fine