I'm using one grunt library for that. It's called Grunt Mocha Test.
It plays well when your mocha tests are for nodejs backend project. I hope my configuration helps you :
mochaTest:
options:
require:
- 'coffee-script/register'
- './test/mocha.coffee'
- 'coverage/blanket'
quiet: true
reporter: 'html-cov'
captureFile: 'coverage.html'
src:
- 'test/**/*.coffee'
The format for my grunt configuration files is in yaml
, because I'm using another plugin that separates the tasks.
my mocha.coffee
file looks something like this :
# Initialize Should for chai
global.chai = require 'chai'
global.chai.use require 'chai-as-promised'
global.chai.config.includeStack = true
global.should = chai.should()