Open dietergeerts opened 6 years ago
Old issue but... I looked into fixing this and it's not simple unfortunately. mocha-headless-chrome
is attaching to the mocha
instance running in the browser and setting it's reporter
to whatever is specified on the command line. So the reporter instance is running in the browser which is not supported by mocha (https://mochajs.org/#options-that-differ-slightly-from-cli-options). And each reporter is responsible for producing the report file (there's not abstraction for the reporter tell mocha "here's my data") so there's no place to hook in to that data and pass it back to mocha-headless-chrome
, you'd have to "fix" each reporter.
The reason it kinda works (structured report info in the terminal output) is that most reporters also do some form of console.log
and mocha-headless-chrome
is already grabbing all the browser console lines and outputting them to the terminal. But because there is other info intermixed (like warnings, errors, etc) it would not be easy or reliable to try to just get the report data.
The only solution I see is to have a special mocha-headless-chrome
reporter that works like the JSONStream
reporter (just logs each test event in JSON form) except that it builds the JSON up in browser memory (in a global variable) so Puppeteer+mocha-headless-chrome can pull it out. Then mocha-headless-chrome
would have to support the reporter API (ie call them directly just like mocha does) and generate the events that the reporter is expecting from the JSON data.
I was expecting to see the reporter output when using --out, but that's not the case. I use xunit reporter, and I see the xml in the terminal, but the file which save the results is a json object:
console:
saved file: