nathanboktae / mocha-phantomjs

:coffee: :ghost: Run client-side mocha tests in the command line through phantomjs
MIT License
954 stars 112 forks source link

Using xunit output with -f option produces empty file #114

Closed rmthamer closed 10 years ago

rmthamer commented 10 years ago

mocha-phantomjs -R xunit -f testfile.xml ./testrunner.html

testfile.xml will show up empty. spec works.

rmthamer commented 10 years ago

I looked into this - xunit is not populating 'Mocha.process.stdout.write' on the page callback (mocha-phantomjs.coffee, line 73). It does however fire "onConsoleMessage", line 46.

I don't have time right now to write up a fix, but I'll look into it in a few days if nothing gets into a pull request.

nathanboktae commented 10 years ago

I took a look. the xunit reporter is using console.log instead of process.stdout.write like every other reporter. This makes it impossible for mocha-phantomjs to distinquish Reporter output from rogue console.log calls in the page being tested, which is a big goal of the feature (see #83).

The correct fix is to fix that reporter. It would be a trivial PR.

nathanboktae commented 10 years ago

Grab the next version of mocha that has that fix or use it straight from GitHub

travisjeffery commented 10 years ago

tons of reporters use console.log including the base reporter.

nathanboktae commented 10 years ago

What's the use case to dump a bunch of xml to the console window if you're not using something like mocha-phantomjs to get the results out?

But yes alot of other reporters use console.log, but the json reporter doesn't, as it requires unformatted output.

nathanboktae commented 10 years ago

@rmthamer Since that PR got reverted, you have two options:

  1. Since mocha-phantomjs supports 3rd party reporters now, take the source of the xunit reporter and make the changes to use process.stdout.write
  2. Just pipe stdout to a file, making sure you have no other console.log calls.

Both of them are good options.

iongion commented 9 years ago

This still issue is still present

jonnyreeves commented 8 years ago

https://github.com/mochajs/mocha/pull/2005 has landed, so we should be good to re-enable xunit reporter file writing?

nathanboktae commented 8 years ago

Nothing was ever specifically disabled - it should just work.

jonnyreeves commented 8 years ago

Doesn't this conditional prevent the use of the file argument?

https://github.com/nathanboktae/mocha-phantomjs/blob/master/bin/mocha-phantomjs#L122

nathanboktae commented 8 years ago

Ah right, I forgot about that :) I'll remove it shortly.

nathanboktae commented 8 years ago

4.0.2 has that check removed.