mochawesome
mochawesome copied to clipboard
Generate mochawesome from Karma
Is there any way to generate mochawesome report from karma? I tried to use "client:mocha:reporter" option from "karma-mocha", but not works =/.
I've only used karma a couple of times and never tried changing the reporter. I would think that if karma-mocha
supports any of the mocha built-in reporters then mochawesome should work. Might want to check with that repo what kind of reporter support they have.
I can confirm this does not work for whatever reason. Perhaps @dignifiedquire or @maksimr can help us here.
Found the issue I believe. The reporter isn't being included in the bundle karma sends to the browser. This is because mocha makes a dynamic require call to get reporters by name.
^^ line 153 in lib/mocha.js
Because this is a dynamic require, it doesn't get included. I'm now looking for a way to force karma to include the reporter so hopefully the require method will return the reporter.
@adamgruber @RobertWHurst first of all client:mocha:reporter
works only for debug page.
Second, we add only mocha.css
to files, so if you want use custom html reporter on debug page, you should add js and css to files
in config or you can pass require
[1] options in client mocha config which contains path to those files.
[1] - https://github.com/karma-runner/karma-mocha#configuration (look at example with require)
Thanks
@maksimr Sounds good. Thanks for the clarification. 👍
I did manage to get mochawesome into the page. Had to screw around with my karma webpack config. I quickly released it wouldn't work. mochawesome was trying to require the fs module. This makes sense. mochawesome is suppose to run in node, and generates the report in a directory. For this to work mochawesome would have to be built to support running inside the browser as the html reporter that ships with mocha does. If said changes were made then theoretically you should be able to load mochawesome with the require option as stated above by @maksimr.
🍻
@RobertWHurst is correct. mochawesome was only ever meant to run in node
is there any technical reason why it couldn't be retrofitted to run in the browser?
hmm, no not that i can think of.
How specific is the code to generate the report to mocha? I just saw this and was thinking, wouldn't it be nice if we could have something nice looking like this as a live dashboard in the browser that karma is currently executing in, or at least at a url like: localhost:9876/dashboard.
@dignifiedquire If you have the right JSON you can create a report. Almost all of the JSON that mochawesome consumes comes from mocha's runner.suite
object. I haven't looked at what karma outputs but I would imagine its similar to mocha and so if you can transform karma's output into what the report generator expects, you can generate a report.
@RobertWHurst can you post karma config here please.
Anybody get this working yet? Would love to get this running in my project.
For reference... and knowledge about this issus take a look here: Karma + Mocha + Reporter
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.