Skip to content

[Bug]: FORCE_COLOR set internally leaks through to tests on Windows after upgrade to Node.js v18.17.0 #14391

Closed as not planned
@aweebit

Description

@aweebit

Version

29.6.2

Steps to reproduce

  1. Install Node.js v18.17.0 on Windows.
  2. Run the following commands in Git Bash:
mkdir jest-force-color
cd jest-force-color
npm install -D jest
echo 'test("color", () => expect(process.env.FORCE_COLOR).toBeUndefined());' > first.test.js
cp first.test.js second.test.js
  1. Open either Git Bash, cmd or PowerShell.
  2. Make sure the FORCE_COLOR environment variable is unset.
  3. Run the following command:
npx jest --no-cache

Expected behavior

I expect the tests to pass.

Actual behavior

Instead, both of them fail because the value of process.env.FORCE_COLOR is '1'.

Additional context

The issue is not present when using Node.js versions prior to v18.17.0. I believe the fact it appears after the upgrade is due to nodejs/node#48034.

The upgrade broke tests in tj/commander.js checking the output of node child processes, and it was quite hard to figure out what the reason was.

Environment

System:
  OS: Windows 10 10.0.19045
  CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
Binaries:
  Node: 18.17.0 - C:\Program Files\nodejs\node.EXE
  Yarn: 1.22.19 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
  npm: 9.8.1 - C:\Program Files\nodejs\npm.CMD
npmPackages:
  jest: ^29.6.2 => 29.6.2

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions