Skip to content

test(fmt): color tests fail when NO_COLOR is set #7322

Open

Description

@tomas-zijdemans

Describe the bug

deno task ok fails when the caller has NO_COLOR set. The color implementation correctly disables ANSI codes, but several tests always expect colored output.

This affects fmt/colors_test.ts, internal/styles_test.ts, and cli/unstable_spinner_test.ts. I ran the focused color tests 10 times with NO_COLOR=1. Every run failed. All 10 passed with the variable unset.

Steps to Reproduce

NO_COLOR=1 deno test -A \
  fmt/colors_test.ts \
  internal/styles_test.ts \
  cli/unstable_spinner_test.ts

As a control:

env -u NO_COLOR deno test -A \
  fmt/colors_test.ts \
  internal/styles_test.ts \
  cli/unstable_spinner_test.ts

The control passes. A full env -u NO_COLOR deno task test run reported 7,462 passed and 0 failed.

Expected behavior

The test suite should control color state instead of inheriting it from the caller. Tests that assert ANSI output should run with colors enabled, while the existing no-color coverage should keep verifying NO_COLOR in an isolated process.

Actual behavior

Deno.noColor is true at process startup, so the implementation returns unstyled strings. Tests such as red() single color still expect ANSI escape codes and fail. setColorEnabled(true) cannot override this because it intentionally respects Deno.noColor.

This does not appear in GitHub Actions because the workflow does not set NO_COLOR. It is a local test-hermeticity problem, not a runtime bug.

Environment

  • OS: macOS
  • deno version: 2.9.6
  • std version: main

Activity

  1. miso-devel commented on Sep 26, 2026

    @miso-devel
    Contributor

    Hello, I'd like to work on this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions