Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
rmthamer opened this issue Dec 11, 2013 · 12 comments · Fixed by mochajs/mocha#1068
Closed

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

rmthamer opened this issue Dec 11, 2013 · 12 comments · Fixed by mochajs/mocha#1068

Comments

@rmthamer
Copy link

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

testfile.xml will show up empty. spec works.

@rmthamer
Copy link
Author

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
Copy link
Owner

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
Copy link
Owner

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

@travisjeffery
Copy link

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

@nathanboktae
Copy link
Owner

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
Copy link
Owner

@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
Copy link

iongion commented Dec 5, 2014

This still issue is still present

@jonnyreeves
Copy link

mochajs/mocha#2005 has landed, so we should be good to re-enable xunit reporter file writing?

@nathanboktae
Copy link
Owner

Nothing was ever specifically disabled - it should just work.

@jonnyreeves
Copy link

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

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

@nathanboktae
Copy link
Owner

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

@nathanboktae
Copy link
Owner

4.0.2 has that check removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants