2

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.

2

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?

|improve this answer|||||
  • 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 – geeks Sep 26 '15 at 7:45
  • plz seee this link stackoverflow.com/questions/32794700/… – geeks Sep 26 '15 at 7:46
  • @geeks you may have an easier time reporting this to the mocha folks on github, t might be a bug – Yamikuronue Sep 26 '15 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 '17 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 – Yamikuronue May 26 '17 at 11:55
2

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

I just tested it, really awesome results.

|improve this answer|||||
  • 1
    What does mochaawesome do differently? – corsiKa Nov 23 '17 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 '17 at 14:08
0

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.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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