-
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
Add console support when jest-junit is used as a reporter #96
Add console support when jest-junit is used as a reporter #96
Conversation
Thanks for addressing this. But I think something is still missing. It looks like you are buffering the console output, but still nothing is being done with it. It doesn't look like |
consoleBuffer[testResult.testFilePath] = testResult.console; | ||
} | ||
}; | ||
|
||
this.onRunComplete = (contexts, results) => { | ||
processor(results, this._options, this._globalConfig.rootDir); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could read consoleBuffer
here and add it back to each result instance before you pass it to processor
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, yep! You're right! Thanks so much for the help there. This is a really helpful feature.
Hi,
I tried executing the test from your repository but still not able to see the console logs on JUnit xml. Did it worked when you tried it?
I verified that this works - if something isn't working on your end do me a favor and submit an issue with steps to reproduce. Keep in mind the caveats to make this work:
|
Thanks. I took a closer look, and you're right that the console output is definitely getting injected into the processor. So no issue there, but I still haven't gotten it to work (actually write to the xml file). Here's my repro: https://github.com/brownbl1/jest-test Anything look off there? |
I think the configuration precedence was likely not great in that example. I may create a bug report from this.. But basically the preferred way of setting configurations for jest-junit is via reporter arguments. This makes it work in your setup. Remove the "jest-junit" key in package.json and replace the "jest" key with this.
|
So turns out your way of configuring was just fine. Just need to switch true to "true" and it works. |
Interesting, yep! You're right! Thanks so much for the help there. This is a really helpful feature. |
HI thanks for the super feature as I need it to work for the test cases to log graphql api failure errors but I am not able to see the console log in junit xml. Please find the jest.config details below and I am using jest 10.0.0 version.
}; |
Jest has removed the ability for reporters to access console output. The configuration still exists in jest-junit because we support older versions of jest. But for modern versions of jest this is no longer a possibility. I'll update the docs to make that clear. |
@palmerj3 do you know witch versions of Jest allow the access to console output? |
I don't recall off hand but I will do the work to dig that up and update the jest-junit README once I know |
@StevenBedoyaB Jest 7.0.0 I guess it works, I will try it out on that version tomorrow. |
Fixes #45
Jest made a breaking change which set console to undefined for onRunComplete for reporters in order to address a memory leak.
This change aggregates console output from onTestResult and adds it to the report.