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

NO_COLOR=1 doesn't turn off intercepted console logging color #4965

Closed
6 tasks done
hi-ogawa opened this issue Jan 15, 2024 · 0 comments · Fixed by #4966
Closed
6 tasks done

NO_COLOR=1 doesn't turn off intercepted console logging color #4965

hi-ogawa opened this issue Jan 15, 2024 · 0 comments · Fixed by #4966
Labels
p1-chore Doesn't change code behavior (priority)

Comments

@hi-ogawa
Copy link
Contributor

hi-ogawa commented Jan 15, 2024

Describe the bug

Test file:

import { test } from 'vitest';

test('console color', () => {
  console.log(['string', /regexp/, 1234, true, null, undefined]);
});

Output:

$ NO_COLOR=1 npm run test
...
stdout | test/repro.test.ts > console color
[ 'string', /regexp/, 1234, true, null, undefined ]       /// <-- this always gets highlighted
Reveal screenshot

image


This is probably because of forced colorMode for the custom Console instance. Since this is node runtime only feature, I think it might be natural to do the same color detection as other places (like reporters) so that NO_COLOR would be also taken into account.

return new Console({
stdout,
stderr,
colorMode: true,
groupIndentation: 2,
})

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-gvgl5a?file=test%2Frepro.test.ts

System Info

(stackblitz)

  System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.18.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.4.2 - /usr/local/bin/npm
    pnpm: 8.14.0 - /usr/local/bin/pnpm
  npmPackages:
    @vitest/ui: latest => 1.2.0 
    vite: latest => 5.0.11 
    vitest: latest => 1.2.0

Used Package Manager

npm

Validations

@sheremet-va sheremet-va added bug p1-chore Doesn't change code behavior (priority) and removed pending triage labels Jan 15, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Jan 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p1-chore Doesn't change code behavior (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants