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

XUnit also for client side tests #40

Closed
t-hg opened this issue Jul 11, 2017 · 7 comments
Closed

XUnit also for client side tests #40

t-hg opened this issue Jul 11, 2017 · 7 comments

Comments

@t-hg
Copy link

t-hg commented Jul 11, 2017

Unfortunately CLIENT_TEST_REPORTER=xunit does not work. Only server side test are exported into xunit xml file.

@singhsoldier13
Copy link

+1

@thebarty
Copy link

thebarty commented Sep 13, 2018

Yeah - plus one.

I get this error:
Load the app in a browser to run client tests, or set the TEST_BROWSER_DRIVER environment variable. See https://github.com/meteortesting/meteor-mocha/blob/master/README.md#run-app-tests

when calling via

SERVER_TEST_REPORTER=xunit XUNIT_FILE=$PWD/unit-integrationa-results.xml meteor test --once --driver-package meteortesting:mocha

@SimonSimCity
Copy link
Member

This should be fixed in version 1.1.0. When you now set the MOCHA_REPORTER to xunit (or separately via SERVER_TEST_REPORTER and CLIENT_TEST_REPORTER) you'll see, that the output of both test-environments will be in the xunit format.

You then should also set SERVER_MOCHA_OUTPUT (which replaces XUNIT_FILE) and CLIENT_MOCHA_OUTPUT to the path you want to see the test reports in.

In case it doesn't work, please make sure that this and the package meteortesting:browser-tests are installed in the latest version and that you run the tests using a headless browser as described in https://github.com/meteortesting/meteor-browser-tests#dependencies (the documentation on this package regarding headless browsers is a bit outdated 😉 - that's why I linked directly to the package providing this feature).

@Floriferous
Copy link

Floriferous commented Feb 4, 2019

Client-side tests don't seem to report properly for me. I can see the file on CircleCI being generated, and its content appears to be ok, but circleCI complains:

screenshot 2019-02-04 at 11 03 42

screenshot 2019-02-04 at 11 03 33

Would you have an idea what could be wrong with the file?

EDIT: It seems that the client test report is simply reading everything off the command line and dumping it into the xml file, so if there are any other logs than test results, the xml file will be invalid. Is there a way to filter for xml lines only maybe?

@SimonSimCity
Copy link
Member

SimonSimCity commented Feb 4, 2019

Well, the truth is, that all the test-results on the client are just written out to the console, which can be grabbed on the server-side.

If you want to dig into it, this is the repository used for getting in contact with the browsers in an abstract way: https://github.com/meteortesting/meteor-browser-tests

I see your problem here, but don't know how to fix it. Mainly because I can't differ between a result from a reporter and a usual console.log() call. I could only do so for console.error() and maybe console.warn(), console.info() or other methods as well listed here https://developer.mozilla.org/en-US/docs/Web/API/Console, but this highly depends on the implementation for each of the browsers.

@Floriferous
Copy link

Floriferous commented Feb 4, 2019

Could we maybe clean up the xml file at the end? It's a bit hacky, but removing any "non-xml" content from the file could already be a coarse filter.

I think it might be safe to say very few people would ever console.log xml-valid content.

EDIT: xUnit xml seems to have a very simple syntax: https://xunit.github.io/docs/format-xml-v2
Removing any non-xml nodes might do the trick?

EDIT2: It looks like what you get from the console isn't even XML, it's formatted text. I'd be surprised if any xml parser can actually read it?

@SimonSimCity
Copy link
Member

Could do that ... I'd prefer a separate issue for this, since the main purpose of this ticket is solved and this (to me) is a separate ticket.

If we would cut out some of the data returned by calling console.log() I'd at least put it out on stdout - not simply ignore it, but this is up for a discussion which I'd take in the new ticket. If you have time, I'd also welcome a PR. Otherwise you'd have to wait until someone else (e.g. me) finds time to pick it up.

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

No branches or pull requests

6 participants