Skip to content

test(common): Add unit tests for cli-colors utility#17069

Merged
kamilmysliwiec merged 1 commit into
nestjs:masterfrom
Se3do:test/cli-colors
Jun 2, 2026
Merged

test(common): Add unit tests for cli-colors utility#17069
kamilmysliwiec merged 1 commit into
nestjs:masterfrom
Se3do:test/cli-colors

Conversation

@Se3do
Copy link
Copy Markdown
Contributor

@Se3do Se3do commented Jun 1, 2026

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe: Add unit test coverage for cli-colors utility

What is the current behavior?

cli-colors.util.ts has no unit tests. This utility provides ANSI color
wrapping for NestJS CLI output (logger, REPL, injector) and respects the
NO_COLOR environment variable standard — yet its color wrapping and
env-var logic are untested.

Issue Number: N/A

What is the new behavior?

Adds packages/common/test/utils/cli-colors.util.spec.ts covering:

  • isColorAllowed() returns true by default
  • isColorAllowed() returns false when NO_COLOR is set
  • clc.green() wraps text in ANSI green codes
  • clc.bold() wraps text in ANSI bold codes (different close sequence)
  • All clc.* methods return raw text when NO_COLOR is set
  • Standalone yellow() uses extended ANSI codes

Uses afterEach cleanup to prevent cross-test env var contamination.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

This change only adds test coverage and does not modify runtime behavior.

Copilot AI review requested due to automatic review settings June 1, 2026 16:49
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds unit tests for the CLI color utility to verify ANSI wrapping behavior and NO_COLOR opt-out semantics.

Changes:

  • Introduces tests for isColorAllowed() default and NO_COLOR-disabled behavior
  • Adds assertions for clc style wrappers (e.g., green/bold) and NO_COLOR passthrough
  • Adds a dedicated test for the yellow() extended ANSI formatter

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/common/test/utils/cli-colors.util.spec.ts Outdated
@coveralls
Copy link
Copy Markdown

coveralls commented Jun 1, 2026

Coverage Report for CI Build 13423

Coverage increased (+0.01%) to 90.039%

Details

  • Coverage increased (+0.01%) from the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 8624
Covered Lines: 7765
Line Coverage: 90.04%
Relevant Branches: 2943
Covered Branches: 2387
Branch Coverage: 81.11%
Branches in Coverage %: No
Coverage Strength: 56.72 hits per line

💛 - Coveralls

@Se3do Se3do force-pushed the test/cli-colors branch from 064a490 to 1634915 Compare June 1, 2026 16:53
@kamilmysliwiec kamilmysliwiec merged commit 1234f97 into nestjs:master Jun 2, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants