-
Notifications
You must be signed in to change notification settings - Fork 109
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
console support #45
Comments
If I get time this weekend I can revisit this. But the last time I looked into it I was worried that it would contain too much irrelevant data. My main worry was if people used the --useStderr cli flag. |
Yeah, I know that Jest buffers console output when running tests concurrently. I wonder if something similar could be done where |
@mfulton26 I THINK that jest already handles this and by the time this information is sent to a testResultsProcessor that it's already in a non-buffered organized format. If I get some time this week I can confirm that. But feel free to send a PR if you have time and I'll review! :) |
Now that this module is a reporter, you can implement this |
I'm looking at this now and it appears to be doable however the spec we abide by appears that system-out is associated with a test suite (which for jest would be an individual test file with many test cases). Would that be useful? I am going to make a PR for the fun of it which adds this and get your feedback. |
Note that it doesn't buffer when |
I've submitted a PR which adds this functionality. Please give me your feedback when you can. I'll leave it open for a few days before merging if there is no feedback. |
@palmerj3 I see the PR was merged. Just added the variable to my jest config as shown: reporters: [
'default',
[
'jest-junit',
{
suiteName: 'Unit Tests',
outputDirectory: '.',
outputName: 'coverage/test-results.xml',
classNameTemplate: '{classname}-{title}',
titleTemplate: '{classname}-{title}',
ancestorSeparator: ' › ',
usePathForSuiteName: 'true',
includeConsoleOutput: 'true',
},
],
], Using 6.4.0 and im not seeing any of my console logs in the my xml report tho :/ I think I have that set up correctly based on the readme. |
I also tried it, same as @TonyG623, and saw no output in my XML report. package.json
jest.config.js
tests/dummy.test.js describe("console log", () => {
test("outputs to XML report", () => {
console.log("nope")
throw "yes"
})
}) XML report: <?xml version="1.0" encoding="UTF-8"?>
<testsuites name="Unit Tests" tests="1" failures="1" time="1.988">
<testsuite name="tests\dummy.test.js" errors="0" failures="1" skipped="0" timestamp="2019-05-03T08:00:06" time="1.905" tests="1">
<testcase classname="console log-outputs to XML report" name="console log-outputs to XML report" time="0.01">
<failure>yes</failure>
</testcase>
</testsuite>
</testsuites> |
Hmm thanks for reporting. Can you both tell me the version(s) of jest you're running this against? (nevermind I see the versions now!) Will take a look |
Not sure if this is related, but could it be a Windows vs. Linux path thing somewhere in your code? Tried cloning the repo and running the tests. Got a bunch of these errors:
|
Hi there, join the discussion again and hope i can help a little bit more this time. Steps to reproduce the error:
I added some debug output to the jest junit project and found, that the console attribute of the suite object is {
console: undefined,
...
} Hope that a concrete example helps to solve the problem or approach the origin of the error. |
I dived a little bit into jest core code and found that ReportDispatcher overrides .console property with undefined. I opened an issue to discuss this: jestjs/jest#8499 |
Is there an update on this? I'm seeing the same behavior? Did any of you find a workaround? |
Hey sorry for the radio silence on this one. It's somewhat complex. I believe I have a fix for jest to re-enable this functionality. Will link the PR here shortly and hopefully it's approved. |
I just published jest-junit 7.0.0 with a fix that should now allow for console output to be written to junit.xml. A few caveats (due to breaking changes in jest):
|
Both of those caveats are bugs in jest... (jestjs/jest#6441 sorta relates, but reporters should always get console output regardless of silent/verbose - it should decide itself based on those options whether to print it or not) |
@palmerj3 are those 2 caveats still true? |
What's the reason to do this:
|
I'm not sure if this is possible but it would be a huge benefit if the results of any
console.log
statements, etc. were made available inside of<testcase>
elements using<system-out>
and<system-err>
.The text was updated successfully, but these errors were encountered: