Skip to content

nx test still emits ANSI codes with FORCE_COLOR=0 in CI #34387

@chenrui333

Description

@chenrui333

Current Behavior

When running nx test in CI, output still contains ANSI escape sequences even when FORCE_COLOR=0 is set.

This breaks tools/tests that parse plain output. Example from Homebrew formula test:

FORCE_COLOR=0 nx test

Expected plain text line:

Successfully ran target test for project @acme/repo

Actual output still includes ANSI escapes around tokens like test and the NX banner.

Expected Behavior

With FORCE_COLOR=0, nx test should not emit ANSI color/style escape sequences.

Steps to Reproduce

  1. Create a minimal package with script:
{
  "name": "@acme/repo",
  "version": "0.0.1",
  "scripts": {
    "test": "echo 'Tests passed'"
  }
}
  1. Initialize Nx:
nx init --no-interactive
  1. Run with forced no-color:
FORCE_COLOR=0 nx test
  1. Observe ANSI sequences in output in CI/non-interactive environments.

Nx Report

Observed on nx 22.5.0 in Linux CI.

Additional Context

CI run showing failure due ANSI output in parser assertion:
https://github.com/Homebrew/homebrew-core/actions/runs/21845716504/job/63041266086?pr=266654

Raw snippet from CI output:

\e[7m\e[1m\e[32m NX \e[39m\e[22m\e[27m  \e[32mSuccessfully ran target \e[1mtest\e[22m for project @acme/repo\e[39m

Potentially related older issues (not exact): #8051, #22731.


Metadata

Metadata

Assignees

Labels

priority: highHigh Priority (important issues which affect many people severely)scope: corecore nx functionality

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions