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

JUnit reporter sometimes adds ansi colors to the report #4958

Closed
6 tasks done
AmirTugi opened this issue Jan 14, 2024 · 4 comments
Closed
6 tasks done

JUnit reporter sometimes adds ansi colors to the report #4958

AmirTugi opened this issue Jan 14, 2024 · 4 comments

Comments

@AmirTugi
Copy link

Describe the bug

Hey, from time to time the JUnit reporter adds ansi colors to my report (not sure what's the rule), and this makes the report unreadable in places like the CircleCI's test results which doesn't show ansi colors.

This is how it looks like:
image

I used to have a NO_COLOR/--no-color flag, but it applies to both reporters
How can I configure the junit reporter to strip the colors?

Reproduction

I will add a stackblitz once I manage to reproduce it in a standalone environment.
Right now I am experiencing this in my local machine.
I'll add a reproduction once I manage to create one 💪🏼

System Info

System:
    OS: macOS 14.2.1
    CPU: (12) x64 Apple M2 Max
    Memory: 23.80 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.10.0 - ~/.volta/tools/image/node/20.10.0/bin/node
    Yarn: 1.22.19 - ~/.volta/tools/image/yarn/1.22.19/bin/yarn
    npm: 10.2.3 - ~/.volta/tools/image/node/20.10.0/bin/npm
  Browsers:
    Chrome: 120.0.6099.216
    Safari: 17.2.1

Used Package Manager

yarn

Validations

@hi-ogawa
Copy link
Contributor

hi-ogawa commented Jan 15, 2024

In your case, color highlight is probably added by testing-library (e.g. @testing-library/react, @testing-library/dom, etc...) and it looks like they adopted a little unusual convention to turning it off by COLORS=false testing-library/dom-testing-library#1166

I tested an example here. Would this help your use case?

https://stackblitz.com/edit/vitest-dev-vitest-8sqonh?file=src%2Fcomponents%2Finput.test.tsx

(Actually, I found a different case where NO_COLOR=1 is not working. I'll create a separate issue for this later #4965)

Copy link

Hello @AmirTugi. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with need reproduction will be closed if they have no activity within 3 days.

@hi-ogawa
Copy link
Contributor

I used to have a NO_COLOR/--no-color flag, but it applies to both reporters. How can I configure the junit reporter to strip the colors?

I mis-understood the request slightly. I suppose you still want to keep the color of other reporter, but just strips ansi code only from junit output. I think always stripping off from junit sounds okay to me. Maybe we can provide an option to switch if there's a strong need of preserving the color there.

@hi-ogawa hi-ogawa added bug p3-minor-bug An edge case that only affects very specific usage (priority) and removed needs reproduction labels Jan 19, 2024
@hi-ogawa hi-ogawa added pending triage needs reproduction and removed bug p3-minor-bug An edge case that only affects very specific usage (priority) pending triage labels Jan 19, 2024
Copy link

Hello @AmirTugi. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with need reproduction will be closed if they have no activity within 3 days.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 24, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Feb 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants