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

Bugfix/xunit browser output #158

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

imajus
Copy link

@imajus imajus commented Sep 20, 2024

This is a fix for the XUNIT reporter output from the client. I was experiencing issues with this when running client tests in headless mode via Puppeteer.

Here's a reproduction repository: https://github.com/imajus/meteor-browser-tests-issue/

Expected to get XML in test-results/client.xml but getting the following contents:

In the test groupIn the test case<testsuite name="Mocha Tests" tests="1" failures="0" errors="1" skipped="0" timestamp="Fri, 20 Sep 2024 05:34:25 GMT" time="0.003">
<testcase classname="Example" name="test" time="0.001"><failure>undefined undefined undefined
AssertionError: undefined undefined undefined
    at Context.&#x3C;anonymous&#x3E; (app/app.js?hash=818e846856c24f4b042929071138d0f3cfb8a773:20:12)
    at callFn (packages/meteortesting_mocha-core.js?hash=dd1ee602c0eabe4198d6106e7f5734b6963d105c:13223:23)
    at Test$4.Runnable$3.run (packages/meteortesting_mocha-core.js?hash=dd1ee602c0eabe4198d6106e7f5734b6963d105c:13211:7)
    at Runner.runTest (packages/meteortesting_mocha-core.js?hash=dd1ee602c0eabe4198d6106e7f5734b6963d105c:14756:12)
    at http://localhost:3000/packages/meteortesting_mocha-core.js?hash=dd1ee602c0eabe4198d6106e7f5734b6963d105c:14879:14
    at next (packages/meteortesting_mocha-core.js?hash=dd1ee602c0eabe4198d6106e7f5734b6963d105c:14671:16)
    at http://localhost:3000/packages/meteortesting_mocha-core.js?hash=dd1ee602c0eabe4198d6106e7f5734b6963d105c:14681:9
    at next (packages/meteortesting_mocha-core.js?hash=dd1ee602c0eabe4198d6106e7f5734b6963d105c:14564:16)
    at http://localhost:3000/packages/meteortesting_mocha-core.js?hash=dd1ee602c0eabe4198d6106e7f5734b6963d105c:14649:7
    at timeslice (packages/meteortesting_mocha-core.js?hash=dd1ee602c0eabe4198d6106e7f5734b6963d105c:20603:29)</failure></testcase>
</testsuite>

As part of this PR there's also a refactoring which makes is easier to handle the MOCHA_REPORTER environment variable value in the source code.

@imajus
Copy link
Author

imajus commented Sep 20, 2024

Resolves this issue.

@imajus
Copy link
Author

imajus commented Sep 20, 2024

FYI the solution is based on the fact that Xunit output can only write to console or process.stdout (if it's present) in a browser. To my knowledge, the process.stdout option is only available for PhantomJS driver.

So the only way to get the Xunit reporter output is to somehow "scrap" it from the console output. Given that it's garanteed to be XML tags, I've implemented a hacky, yet seemingly reliable solution to filter out all non-XML-like lines from the browser's console log when piping the output to a file. Additionally, the filtered out console log lines aren't just thrown away silently, but are instead logged in the server execution log.

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 this pull request may close these issues.

1 participant