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

reporter output empty #161

Closed
iongion opened this issue Nov 21, 2014 · 6 comments
Closed

reporter output empty #161

iongion opened this issue Nov 21, 2014 · 6 comments

Comments

@iongion
Copy link

iongion commented Nov 21, 2014

when running:

mocha-phantomjs -s localToRemoteUrlAccessEnabled=true -s webSecurityEnabled=false -R xunit -f xunit-dump.xml http://localhost:9000/tests.html

I see all my tests running, but there is nothing inside the report file, it is empty and the xunit output is sent to stdout, together with console.log messages

@nathanboktae
Copy link
Owner

Yeah xunit outputs to stdout instead of using Mocha.process.stdout. See #114

@iongion
Copy link
Author

iongion commented Dec 5, 2014

But this is not fixed in mocha:
https://github.com/mochajs/mocha/blob/master/lib/reporters/xunit.js

still has console.log and not only that, all the reporters use console.log and console.log is needed as mocha is made to work in the browser too.

wouldn't a better fix be detecting the running environment (phantom or browser) first and then deciding to use console.log or process.stdout.write ?

@iongion
Copy link
Author

iongion commented Dec 5, 2014

I have replaced all occurrences of console.log with process.stdout.write, the xunit xml output is still garbage, containing console log output from the browser too.

  • you cannot control console.log calls of apps that are being tested, that output should be sent to the xunit test case who's context it is executed
  • it is not fair to force users not to use console.log in their tests
  • page.onConsoleMessage shoud accumulate output in a list per test case

in its shape, current xunit runner is really garbage, would try to fix it myself but I have no idea where to start, I've worked with qunit before and I've used the its hooks to create a usable xunit reporter for jenkins available here:

https://gist.github.com/iongion/f23edaa708eafc240a8b

In page.onConsoleMessage as you can see I accumulate logs per test step
(async tests console logs are problematic)

@nathanboktae
Copy link
Owner

So do you understand the fundamental problem? reporters, mocha, and your apps under test all use console.log, so you can't separate it out without doing hacky shit like looking up the call stack to see who's calling you. It needs to be a different channel, and process.stdout.write is available in both node and other environments as the compiled version creates a process variable and compiles that in the closure of the compiled version of Mocha, exposes it as Mocha.process so that mocha-phantomjs and mocha-casperjs too can pipe the output elsewhere - in the case of --file, to a file stream.

Where did you replace all occourences of console.log? in just xunit.js or the compiled mocha.js?

@iongion
Copy link
Author

iongion commented Dec 5, 2014

replaced them in the xunit.js but not the compiled mocha.js and yes, i guess i understand where hell is coming from as I've been bitten by it myself in qunit test runner, honestly would really like to have this working for jenkins or other xunit consumers

@nathanboktae
Copy link
Owner

I have replaced all occurrences of console.log with process.stdout.write, the xunit xml output is still garbage, containing console log output from the browser too.

I have a test case for that scenario to ensure it does actually work, so you'll have to dig in what's different for you

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

No branches or pull requests

2 participants