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

[Bug]: FORCE_COLOR is not passed to child process #12162

Closed
memeplex opened this issue Dec 19, 2021 · 4 comments
Closed

[Bug]: FORCE_COLOR is not passed to child process #12162

memeplex opened this issue Dec 19, 2021 · 4 comments

Comments

@memeplex
Copy link

memeplex commented Dec 19, 2021

Version

27.4.5

Steps to reproduce

(Not really steps to reproduce, but I've tracked down the problem after two hours of debugging, so please don't dismiss it too quickly)

In previous versions (26.2.2 is the one I tested) the following code:

import { runCLI } from '@jest/core';

process.env.FORCE_COLOR = '1';

runCLI(...);

printed a colorized output. Something changed in between and I now have to reorder it as follows:

process.env.FORCE_COLOR = '1';

import { runCLI } from '@jest/core';

runCLI(...);

I'm rather sure that this is because chalk is being imported earlier and the default profile is built in a way that doesn't supportsColor.

Expected behavior

Setting FORCE_COLOR in the same process before calling runCLI should make the output colorized.

Actual behavior

The output is not colorized.

Additional context

I believe the issue has some importance, at least this behavior should be documented. When testing vscode extensions inside a extension host sometimes there is no reasonable way to preset the environment and export it from a parent process. True, one can add the export to the system initialization profile, but that's not friendly to collaborators, having this as part of the initialization of the suite is preferable (indeed this way it's at the same level than the non-functional runCLI(...colors: true...)).

Environment

System:
    OS: macOS 11.6
    CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
  Binaries:
    Node: 17.0.1 - /usr/local/bin/node
    Yarn: 1.22.17 - /usr/local/bin/yarn
    npm: 8.1.0 - /usr/local/bin/npm
  npmPackages:
    jest: ^27.4.5 => 27.4.5
@F3n67u
Copy link
Contributor

F3n67u commented Mar 6, 2022

@memeplex Thanks for your report. I am a little confused that you report a bug at jest version 27.4.5 but the foam repo still uses version 26. I tried to move process.env.FORCE_COLOR = '1'; after the import but cannot reproduce.

Could you extract a minimal reproduction repo for this bug report?

@github-actions
Copy link

github-actions bot commented Mar 6, 2023

This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Mar 6, 2023
@github-actions
Copy link

github-actions bot commented Apr 5, 2023

This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Apr 5, 2023
@github-actions
Copy link

github-actions bot commented May 6, 2023

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 6, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants