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

Add support for console output #90

Merged
merged 3 commits into from May 2, 2019

Conversation

palmerj3
Copy link
Collaborator

Adds a new boolean option "JEST_JUNIT_INCLUDE_CONSOLE_OUTPUT" | "includeConsoleOutput" which is false by default. If set to true, and your test suite(s) generate some stdout/console output it will look similar to this in the generated junit.xml:

<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="jest tests" tests="2" failures="0" time="0.941">
  <testsuite name="bar" errors="0" failures="0" skipped="0" timestamp="2019-03-11T16:33:54" time="0.416" tests="1">
    <system-out><![CDATA[[
  {
    "message": "I am bar",
    "origin": "/Users/jpalmer/Desktop/test/__tests__/bar.test.js:5",
    "type": "log"
  },
  {
    "message": "Some output here from a lib",
    "origin": "/Users/jpalmer/Desktop/test/sample.js:3",
    "type": "log"
  }
]]]></system-out>
    <testcase classname="bar should bar" name="bar should bar" time="0.005">
    </testcase>
  </testsuite>
  <testsuite name="foo" errors="0" failures="0" skipped="0" timestamp="2019-03-11T16:33:55" time="0.042" tests="1">
    <system-out><![CDATA[[
  {
    "message": "I am foo",
    "origin": "/Users/jpalmer/Desktop/test/__tests__/foo.test.js:3",
    "type": "log"
  }
]]]></system-out>
    <testcase classname="foo should foo" name="foo should foo" time="0.001">
    </testcase>
  </testsuite>
</testsuites>

This PR also improves the documentation in README so it's more clear how to configure jest-junit as a reporter.

@palmerj3 palmerj3 mentioned this pull request Mar 11, 2019
@palmerj3
Copy link
Collaborator Author

@SimenB any idea why jest 22 fails in this PR? It's related to babel-jest.

I removed it from travis checks since I usually check against the last two versions of jest. But if there is a legit problem let me know. Didn't seem related to this PR.

@SimenB
Copy link
Member

SimenB commented Mar 11, 2019

Haven't dug into it, but do you install the same version of both babel-jest and jest?

@palmerj3
Copy link
Collaborator Author

It should. It has a pretest script that installs the version of jest we're testing against.

"pretest:ci": "npm install jest@$JEST_VERSION",

@SimenB
Copy link
Member

SimenB commented Mar 11, 2019

Yeah, but babel-jest?

@palmerj3
Copy link
Collaborator Author

I don't explicitly install babel-jest. Just jest.

@SimenB
Copy link
Member

SimenB commented Mar 11, 2019

Right, but jest pulls in babel-jest, and tries to require it from the user's node_modules. So if the wrong version is hoisted, things'll blow up. This is essentially d00e122 from #81

@palmerj3
Copy link
Collaborator Author

Ayyy that fixed it. Thanks @SimenB

@TonyG623
Copy link

Was just looking to do exactly this! Nice. Looking forward to this change.

@TonyG623
Copy link

@palmerj3 any idea when this will be available?

@palmerj3
Copy link
Collaborator Author

@TonyG623 I'll try to merge this today and push a minor release. The PR was open for feedback and I haven't gotten any :) I'm not super familiar with the needs that folks have when showing console data in junit files. I've wrapped the data in a CDATA block and the data I show is a jest data structure that shows the source file and the console output itself. Have a look and let me know if you think that would work for your use-case.

@TonyG623
Copy link

TonyG623 commented Apr 1, 2019

@palmerj3 my goal is to get console logs to show in jenkins results. We have less than ideal Selenium tests that log some output as the test runs that help debugging when something fails. Currently all that logging is lost. If its in the XML report it displays there.

Here is how it looks now with your example.. its not pretty , but it currently shows... Which is way better than we currently have.

https://i.imgur.com/pjwDxDP.png

@palmerj3
Copy link
Collaborator Author

palmerj3 commented Apr 1, 2019

@TonyG623 would that work for your use-case?

@TonyG623
Copy link

TonyG623 commented Apr 2, 2019

@palmerj3 I believe it will work for us.

@jkblume
Copy link

jkblume commented Apr 30, 2019

Hi,

thanks for your work on this. What is blocking that PR on being merged? If something has to be done, i can give some time to help solving issues.

@palmerj3
Copy link
Collaborator Author

@jkblume thanks! If you're able to test this branch on your CI environment and see if the output is useful that would be great.

I can get this merged today.

@ghost
Copy link

ghost commented May 2, 2019

I would also love this, any idea when it would be ready for use?

@palmerj3 palmerj3 merged commit 108ff18 into jest-community:master May 2, 2019
@palmerj3
Copy link
Collaborator Author

palmerj3 commented May 2, 2019

Just published 6.4.0 - give it a shot and file an issue if there are any problems.

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.

None yet

5 participants