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.
Asked
Active
Viewed 1.2k times
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.
jazzmn77
- 31
- 2
-
1What 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
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?
Yamikuronue
- 3,372
- 4
- 21
- 45
-
1I have same problem I tried
mocha -R htmlbut getting error/usr/local/lib/node_modules/mocha/lib/reporters/html.js:263 var div = document.createElement('div'); ^ ReferenceError: document is not defined– neelabhsingh Sep 26 '15 at 07:45 -
plz seee this link http://stackoverflow.com/questions/32794700/running-mocha-test-but-getting-error-referenceerror-document-is-not-defined – neelabhsingh Sep 26 '15 at 07: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 07:48
-
1I 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 06: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
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.
demouser123
- 3,532
- 5
- 28
- 40