If anyone knows any examples for generating an html report in the Mocha framework, please share it. I have done googling and tried a lot but I have not been successful.

3 Answers 3


You could give mochawesome a try which you can find here: https://github.com/adamgruber/mochawesome

I just tested it, really awesome results.

  • 1
    What does mochaawesome do differently?
    – corsiKa
    Nov 23, 2017 at 18:53
  • With mochawesome I can start my tests automatically in the night (via node.js) and it will produce a nice looking html file until i get up.. pushed to my webserver.. That seems not to be possible with the standard html reporter as mentioned in the comment above (Calrion May 25 at 6:22) which says that the standard html reporter depends on browser usage.. which was my impression, too.
    – jazzmn77
    Nov 24, 2017 at 14:08

Looking at the source code for mocha: https://github.com/mochajs/mocha/tree/master/lib/reporters

It appears that there's a built-in HTML reporter. Have you tried running mocha -R html?

  • 1
    I have same problem I tried mocha -R html but getting error /usr/local/lib/node_modules/mocha/lib/reporters/html.js:263 var div = document.createElement('div'); ^ ReferenceError: document is not defined Sep 26, 2015 at 7:45
  • plz seee this link stackoverflow.com/questions/32794700/… Sep 26, 2015 at 7:46
  • @geeks you may have an easier time reporting this to the mocha folks on github, t might be a bug Sep 26, 2015 at 7:48
  • 1
    I recently received the same error, and my impression (given document.createElement() is a DOM function only available in a browser-like environment) was that the HTML reporter included in Mocha requires a browser and is unsuitable for generating HTML test output from a non-browser (e.g. Node.JS) environment.
    – Calrion
    May 25, 2017 at 6:22
  • @Calrion I suggest mentioning this on their issue tracker; the developers behind mocha should be able to confirm or deny that that is the case May 26, 2017 at 11:55

I suppose Allure reporter also integrates with Mocha tests. You can take a look at allure-mocha for more information.

I haven't used it though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.