Grunt / Jenkins / Mocha

If you are using Grunt to build your Javascript application and test it using Mocha, you can also enable Jenkins test reporting which will give you graphs and stuff (hopefully).


mocha: {
  report: {
    options: {
      run: true,
      log: true,
      reporter: 'XUnit',       # note - case-sensitive
      urls: [
        'http://localhost:<%= connect.options.port %>/test.html'
    dest: '.tmp/report.xml'

And add a mocha:report task to your Grunt task (such as report) as necessary.


Add a build step grunt report after whatever else you might need to do (e.g. cd test && bower install if you are using Yeoman generated applications).

You shouldn’t install the xUnit plugin for Jenkins. It is expecting a totally different input format to that provided by the Mocha XUnit reporter.

Instead, you can just use the inbuilt “Publish JUnit test result report” post-build action provided by Jenkins, using the report XML generated by Mocha (e.g. .tmp/report.xml).

Caused by: . (Is a directory)

ERROR: Publisher org.jenkinsci.plugins.xunit.XUnitPublisher aborted due to exception
hudson.util.IOException2: There are some problems during the conversion into JUnit reports: 
	at org.jenkinsci.plugins.xunit.service.XUnitTransformer.invoke(
Caused by: org.jenkinsci.plugins.xunit.exception.XUnitException: Conversion error Conversion Error
	at org.jenkinsci.plugins.xunit.service.XUnitConversionService.convert(
Caused by: . (Is a directory)

This is what will happen if you are trying to use the xUnit plugin for Jenkins with the XUnit files generated by the Mocha XUnit reporter. Downgrading to 1.58 didn’t help. Just use the JUnit plugin.