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
fix(vitest): strip ansi code from console output in junit reporter #5007
Conversation
✅ Deploy Preview for fastidious-cascaron-4ded94 canceled.
|
I remember adding this environment variable for reporters test case just because of this issue. Can we now remove it from here? vitest/test/reporters/package.json Line 6 in a4ae574
|
const resultJson = parse(metaJson.replace(new RegExp(vitestRoot, 'g'), '<rootDir>'), (_key, value) => { | ||
return typeof value === 'string' ? stripAnsi(value) : value | ||
}) |
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.
NO_COLOR
was also affecting html reporter, so I stripped it just for this test case.
I am not sure why this is a problem. |
I think it makes sense for users to keep colors enabled for reporters that output on terminal on CI. But they would still like to generate other reports on file system and keep their content human-readable. |
I haven't properly followed up with the issue author #4958 but I assumed that's the intention and made sense to me as a default junit reporter behavior. But, disabling entirely by |
It just looks too irreversible to me. As @hi-ogawa, what if the color is expected? I think we can add an option to toggle this. We can even disable colors by default if you think it is a better experience for most people. |
Thanks for the discussion. Yeah, I'll re-consider this change. Also, it's better to wait for the issue author's response to know the actual experience with current junit output and measure the significance of the issue. I will put this back to draft for now. |
Another approach for this would be support for reporter options. I would imagine something like: {
test: {
reporters: ["verbose", ["junit", { color: false }], "html"],
},
} This was mentioned here #3691 (comment) but no actions were taken. This would also benefit third party reporters. |
I think that would be nice to support but we didn't create an issue yet, true. |
That sounds good to me. I created an issue here #5042 |
Now that #5042 is finished, the JUnit reporter accepts some reporter options: vitest/packages/vitest/src/node/reporters/junit.ts Lines 15 to 19 in 5ed537f
Maybe a new option should be introduced there, |
@AriPerkkio Thanks for the ping. For this junit issue, I'm becoming less convinced about this feature, so I'll close this for now. I think we can reconsider this if we get more reports. |
Description
I'm not sure the need of preserving color for this logging output, so I propose to always strip it for junit without configuration to toggle color. Please let me know if this makes sense.
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yaml
unless you introduce a new test example.Tests
pnpm test:ci
.Documentation
pnpm run docs
command.Changesets
feat:
,fix:
,perf:
,docs:
, orchore:
.